Tuesday, August 26, 2008

[UNIX] Change sshd port to avoid most brute force attempts (Ubuntu example)

In order to change your ssh port in ubuntu via command line, edit /etc/ssh/sshd_config:


sudo vi /etc/ssh/sshd_config


Now, change the Port line:


...
# What ports, IPs and protocols we listen for
Port 22
...


to "Port 21234" or whatever you want it changed to.
Now restart the ssh daemon:


sudo /etc/init.d/ssh restart


You may also need to verify that the port isn't already reserved for something else in "/etc/services".

Remember to open up an router/switch in front of your server, otherwise you'll never be able to contact your server on the new port.

Most other distributions have similar location for the ssh port, you just have to look for it.

No comments: