A Practical Guide To Securing OpenSSH
minklinks.com
minklinks.com
e.g.
ListenAddress 1.2.3.4 #This is not really your IP address.
You can go an extra step and drop all packets to the SSH port on the public interface in IPTables, if you want. It strikes me as being overkill but, hey, whatever.
If you need to log into any server, you do so by tunneling through your gatekeeper server. That fellow gets locked down tightly. All of your other servers are firewalled tight as drums, with the exception of public-facing HTTP servers who have 80 and 443 opened (and that is it).
This makes a bigger difference as well if you have more than a few people accessing the boxes, and for purely remote-based businesses quite a few use this type of setup to host their 'internal' network tools like an intranet, file storage, internal wiki etc.
If you have the cash and capability, I'd recommend an IPSEC VPN over OpenVPN (using something like a low-end Cisco ASA for example, but shop around - the point is to use dedicated hardware), but if you're starting out, OpenVPN is fine.
Host securebox
#if not proxying
HostName securebox.tld
Port 1023
User fji00random
#if going through a gateway
ProxyCommand ssh gatewaybox.tld nc securebox.tld 22
#if knocking
ProxyCommand proxyknock %h %p 1337 1337 900
With that, you can have ssh securebox
rather than knock securebox.tld 1337 1337 900; ssh -p 1023 fji00random@securebox.tld
(and for systems without a knocker installed, you can use something like http://sprunge.us/HJHB for proxyknock, which can be cloned along with the rest of your dotfiles/scripts)And if you're doing public key auth, read about ssh-agent, it can store your private keys in memory so that you don't have to retype your passphrase all the time, while the "physical" key is still protected if stolen. In my bash_profile, I have
SSHAFILE=/tmp/.$(whoami)-ssha
if [ -n "$SSH_AUTH_SOCK" ]; then
echo "We has auth!"
elif [ -f $SSHAFILE ]; then
. $SSHAFILE
else
eval `ssh-agent | tee $SSHAFILE`
chmod 600 $SSHAFILE
ssh-add
fi
This runs ssh-agent if it's not running, and sets proper env variables if it is.(also, the ssh-agent can be forwarded, so you can use your private key to auth into box C, from box B, while the key is only on your local box, A - this can also be added to your .ssh/config)
However, if you're vulnerable to the scanners then you haven't actually addressed the vulnerability they exploit. What you're looking at is a form of security by obscurity that reduces the number of low end attacks, but if someone port scans you, finds the SSH port and runs the same attacks you're still going to get compromised.
Another thing to consider is that if you're moving SSH ports your OS will still respond to requests to connect over SSH by telling the scanners that there's no SSH service running on that port. If you're being metered for bandwidth by bytes transferred it shouldn't be a lot (unless you're getting really hammered by it, which tends to happen when the IP address has been previously compromised).
The correct way to deal with this is to use only public key authentication (which stops people getting in through password brute forcing) and to block the port with a firewall with exceptions for the places that you access it from. You can find out where you're accessing it from by going through the SSH logs.
By all means swap ports if you want to, but don't rely on it alone.
$ sudo grep sshd /var/log/messages* | wc -l
23084
Of course I connect several times a day, however you see the sheer number of scans, the oldest message log is less than one month old.I think it was a valid concern to have if SSH2 hadn't been audited at the time, given that you're trading known issues for an unknown solution that may or may not work, but to infer he thinks SSHv1 is more secure than SSHv2 in that post is slightly inaccurate.