| Tuesday May 24th 2016

Security 101: Running SSH on an alternate port

Changing the port sshd listens on is a simple and necessary security process; it’s just a matter of updating your sshd_config file and then reloading the new configuration.

Use the procedure below to change the port that sshd is listening on to 6969:

Warning: Incorrectly following this procedure may render your server unreachable through SSH. Be careful and do it locally before trying remotely.

1. From your terminal, we need to edit /etc/ssh/sshd_config as root:
# nano /etc/ssh/sshd_config

2. Look for the following line:
#Port 22
3. Change the line, by removing the # and changing the number, so it looks like this:
Port 6969
4. Save and close the file.
5. Load the new configuration by restarting the sshd service:
/etc/init.d/sshd restart
or by using the RedHat service command:
# service sshd reload

Note: you may immediately lose connectivity to your server on the open ssh session you are currently running.

6. Test the connection
$ ssh username@myhostnaname.com -p 2995

Take note of the -p 2995 flag used when connecting to the server. If you are using OS X or a Linux desktop system like Mandriva or Ubuntu, you’ll need to specify the port number when connecting. If you’re using PuTTy on Windows, you can specify the port number in the profile for you connection and then re-save the profile using the new port.

Related Posts: On this day...

Leave a Reply

You must be logged in to post a comment.