Hundreds of failed ssh logins

You can use iptables to rate-limit new incoming connections to the SSH port. I’d have to see your entire iptables configuration in order to give you a turnkey solution, but you’re basically talking about adding rules like: iptables -A INPUT -p tcp –dport 22 -m recent –update –seconds 60 –hitcount 5 –name SSH –rsource -j … Read more

Running Cron every 2 hours [duplicate]

An asterisk in the minute (first) field tells it to run every minute, regardless of the other fields. You need to specify an exact minute to run within the hour. Be that on the hour (0), half past (30), etc.. 0 */2 * * * /path-to-script

Is there a proper way to clear logs?

You can use: > /var/log/mail.log That will truncate the log without you having to edit the file. It’s also a reliable way of getting the space back. In general it’s a bad thing to use rm on the log then recreating the filename, if another process has the file open then you don’t get the … Read more

Curl: disable certificate verification

Yeah, you can do that. From curl –help or man curl: -k, –insecure (SSL) This option explicitly allows curl to perform “insecure” SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered “insecure” fail unless -k, –insecure is … Read more

What’s wrong with always being root?

If you’re logged in as root, you can easily wipe directories or do something that in retrospect is really dumb on the system with the flip of a finger, while as a user you normally have to put a few extra mental cycles into what you’re typing before doing something that is dangerous. Also any … Read more

How can I fully log all bash scripts actions?

I generally put something similar to the following at the beginning of every script (especially if it’ll run as a daemon): #!/bin/bash exec 3>&1 4>&2 trap ‘exec 2>&4 1>&3’ 0 1 2 3 exec 1>log.out 2>&1 # Everything below will go to the file ‘log.out’: Explanation: exec 3>&1 4>&2 Saves file descriptors so they can … Read more