Locking Down SSH with hosts.allow
Posted in Computers on August 19th, 2010 by hurt – Be the first to commentAfter installing my new file server I started to notice the large amount of ssh attempts to log into the box. For a very long time I have been using hosts.allow to tighten things up a little. Figured a good place to keep this info and help others might be to make a blog post of how I use this.
edit /etc/hosts.allow
sshd : localhost : allow
sshd : 192.168.2. : allow
sshd : 192.168.3. : allow
sshd : 199.12.12.12 : allow
sshd : ALL : deny
Enter the above info in your hosts.allow file. You can add as many IP address as you want to be allowed. End this all with the last line to deny everything else that is not listed above it. I would suggest setting this up at a time you have physical access to the box. This might not work for everyone since some people might just around from place to place and have random locations. I tend to just be logging in from home and work. Although I have not used it you could also use a range of ips. If you are always on a certain ip range but not the same ip you could do this.
sshd : 199.12 : allow
sshd : ALL : deny
Enjoy and don’t lock yourself out of your own box. ;)








