1/26/2006
Five Tips for Securing SSH
These snippets are all options in the sshd_config file, located at /etc/ssh/sshd_config on most Linux distros.
In order of increasing security
- Dissallow SSHv1 and force SSHv2 connections
Protocol 2
SSHv1 is now considered unsecure.
- Limit the number of SSH connection attempts at one time
MaxStartups 2
or
MaxStartups start:rate:fullFrom the sshd_config manpage
Alternatively, random early drop can be enabled by specifying the three colon separated values "start:rate:full" (e.g., "10:30:60"). sshd will refuse connection attempts with a probability of "rate/100" (30%) if there are currently "start" (10) unauthenticated connections. The probability increases linearly and all connection attempts are refused if the number of unauthenticated connections reaches "full" (60).
This one is good to slow up automated brute force password bots.
- Dissallow direct root login
Permit no root login attemptsPermitRootLogin noor
Permit root login attempts only via keys in authorized_keys filePermitRootLogin without-passwordThis is the method I usually go for. It prevents brute-force root attempts but still allows for easy enough access. If someone has your private key, you have more problems anyway.
- Change the port SSH listens to. If a hacker cannot find what port SSH is listening on, he cannot very easily try to brute force the password. Change the default port 22 to random non-used port number
Port 22
All valid users will need to adjust their SSH connections to use the new SSH port.
- Disable all password authentication and rely solely on public key authentication
PasswordAuthentication no
All valid users must have a public/private key pair installed on the remote host and their local workstation or any other client that they will access the remote host with.
Make sure you load these changes by restarting the SSH server. On most Linux systems this can be accomplished with:
or
More information on each of these settings can be found in the sshd_config manpage
Popularity: 20%



October 19th, 2006 at 6:50 pm
You are what I aspire to be. I was a railroad conductor for many years then went back to college and got interested in Linux and the web now on a very limited basis I do what you do and love it. I am looking for a 6-5 and am thinking that free lancing may be the way I really want to go. Thanks for putting your site up here so I can see the success you enjoy. These SSH tips are good and yep I know its just from the man page I hadn’t reat entirly. Good stuff none the less
THANKS
Dave Fulwiler
Milwaukee WI