SSH (Secure Shell) is the most popular protocol for connecting remote Linux systems. Changing the SSH port will provide you an extra layer of security. It will be little hard to identify the new port for hackers.
Most of the Linux distributions uses OpenSSH as the default tool for remote login with the SSH protocol. It encrypts all traffic through out the route and provides higher level of security. This article describes you to change OpenSSH server port on a Linux system.
Change SSH Port in Linux
Changing SSH port is an straight forward process in Linux systems. Any system can use port range 0 to 65535, For TCP, port number 0 is reserved and cannot be used. The default SSH service listen on port 22. Just this port with some other ports.
To change SSH port, edit OpenSSH configuration file:
sudo nano /etc/ssh/sshd_config
- Change from – Search for the below line, default it can be commented.
- Change to – Remove ‘#’ symbol from prefix to uncomment above line, Then replace 22 with a non-standard port like:
To save and close file press
CTRL + X keys, then press ‘y’ and hit enter button.
Now, restart the SSH daemon to apply changes.
sudo systemctl restart ssh
That’ it. The SSH service is now running on a new port defined above.
Connect System with New SSH Port
The SSH service is listening on a non-standard port. So, you have to provide port number while connecting server thought ssh.
Use the following command from client machine to connect remote server on a new port.
ssh -p 2232 [email protected]
The rsync user follow these instructions to connect remote system on a different port.
This tutorial helped you to secure your Linux server by changing SSH port to a non-standard port.