In this tutorial we will see the steps for changing the default SSH port under a server running Ubuntu 11.10. The SSH server uses by default port 22 and if changed, you may be secure from some automated bot-based SSH attacks on your server because it will be difficult to guess the new SSH port.

Getting Started

Open the terminal and edit the /etc/ssh/sshd_config file with this command:

gksudo gedit /etc/ssh/ssh_config
gksudo nano /etc/ssh/ssh_config

Locate now this line (22 is the default SSH port):

Port 22

Change 22 to any appropriate port of your choice, then save your file and exit:

Restart now the SSH server with this command to take into account the new selected port:

sudo /etc/init.d/ssh restart

To test the new port, you can use this command by replacing username@hostname.com and 50692 with the new port selected and your own SSH details:

ssh username@hostname.com -p 50692

Note: This tutorial is done under Ubuntu 11.10 and is workable for older versions of Ubuntu.

Post a Comment