What measures can/should I take to make sure that security around my SSH server is absolutely impermeable?
This will be community wiki from the start, so lets see what people does to secure their servers.
|
|
Use public/private key pairs for authentication instead of passwords.
Now, the only possible way to SSH into the server is to use a key that matches a line in |
|||||||||||||||
|
|
I would suggest using fail2ban to prevent brute force login attempts. Disabling logging in as root via SSH. This means an attacker had to figure out both the username and the password making an attack more difficult. Add Limiting the users that can SSH to the server. Either by group or just specific users. Add |
||||
|
|
|
Make the sshd block client IP's that have failed to supply correct login information "DenyHØsts" can do this job quite effectively. I have this installed on all my Linux boxes that are in some way reachable from the great outside. This will make sure that brute force-attacks on the sshd wont be effective, but remember! this way you can end up locking your self out if you forget you password. This can be a problem on a remote server that you don't have access to. |
||||
|
|
|
Other answers provide security, but there is one thing you can do which will make your logs quieter, and make it less likely that you'll be locked out of your account: Move the server port from 22 to another port. Either at your gateway, or on the server. It doesn't increase the security, but does mean all the random internet scanners won't clutter up you log files. |
|||||||||
|
|
Here's one easy thing to do: install ufw (the "uncomplicated firewall") and use it to rate limit incoming connections. From a command prompt, type:
If ufw is not installed, do this and try again:
Many attackers will try to use your SSH server to brute-force passwords. This will only allow 6 connections every 30 seconds from the same IP address. |
|||||
|
|
There is a Debian Administration article on this topic. It covers basic SSH server configuration and also firewall rules. This could be of interest also to hardened an SSH server. See there article: Keeping SSH access secure. |
|||||
|
|
If I want to have some additional security or need to access SSH servers deep inside some corporate network I setup a hidden service by using the anonymisation software Tor.
Furthermore I need Tor on my local host. If it is installed I can enter |
||||
|
|