Wednesday 3 July 2013

Running an SSH Server on Multiple Ports (Without restarting service)

There are a lot of reasons you could need to run sshd (the ssh server) on a port other than the standard port 22.  Sometimes you have too many hack attempts on port 22,  I moved my sshd to a high port number on one server for the first reason.It's pretty easy to do on your Linux box.
 On the machine that's running sshd, the ssh server,

 edit /etc/ssh/sshd_config.

                                     SSH-Secure Shell


Since 22 is the default value for Port, sshd will behave the same if you have no Port directive at all or if you have this comment.The lines that have no # in front of them are directives. 


If you want to have sshd listen on
ports 22, 8081 and 2013 you need lines like this
Port 22 
Port 8081
Port 2222

Reload the service (note: this command  will not restart the service) 
# /etc/init.d/sshd reload     
Or
#service sshd reload 

To log into a system that is running ssh on an unusual port, include the port number 
in the ssh command like this:
# ssh -p 8081 user@your-ip
OR
# ssh -p 2222 user@you.homenetwork.com

No comments:

Post a Comment