The Secure Shell (SSH) Protocol is using by default port 22. As a virtual/dedicated server administrator, it’s always a good idea to change this. Changing the port to another number will stop many attacks – as attack tools will try to connect to port 22.
To change the SSH port:
- Log in to your server as root.
- Open the /etc/ssh/sshd_config file in a text editor (like vi, nano etc.).
- Look for the line
- Change the 22 value to 3700 for example. You can use a port from the User Ports Interval (1024-49151), as assigned by the Internet Assigned Numbers Authority (IANA).
- Save the file, exit the editor and restart the SSH server.
service sshd restart
- Open a new terminal window (or using PuTTY) and try to connect to the new assigned port:
ssh firstname.lastname@example.org 3700
Port numbers are assigned in various ways, based on three ranges: System Ports (0-1023), User Ports (1024-49151), and the Dynamic and/or Private Ports (49152-65535); the difference uses of these ranges is described in [RFC6335].
Related KB article: How to install nano editor with yum