How to change SSH port number on Ubuntu server

September 3rd, 2010 | Tags: , , , ,

Changing the port number of SSH daemon is a quick way of reducing the number of SSH brute force attacks your server might face (check the file /var/log/auth.log to see if there are many failed SSH login attempts).

  1. Just to be on the safe side, create a backup copy of the SSH daemon config file.

    sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.vanilla

  2. Edit the config file.

    sudo vi /etc/ssh/sshd_config

  3. Change the port number on the following line, e.g. to 2201 or some other unused port. Make sure you note down the port number.

    Port 22

  4. Restart the SSH daemon. You might get kicked out of your existing session.

    sudo /etc/init.d/ssh restart

  5. When you login next remember to include the correct port.

    ssh youruser@yourserver -p 2201

No comments yet.