Sunday, October 27, 2013

How to Change SSH Port Number in Linux

It is highly recommended to change ssh port number and it is a good security practice for an administrator. By default ssh port number is 22 and you can change with any non usable port numbers. 

[root@
123schools.blogspot.in~]# cat /etc/services

In the above command, services file display all the service names with associated default port numbers. If you are not using that port then you can select any port.

Open the sshd configuration using a vim editor.
vim /etc/ssh/sshd_config

Change from Port 22 to Port 2220 or any other (ex: 2222, 2221, 2028 etc...)
After implementing your required changes, save and quit from the configuration file and restart the ssh service. Service restart as shown below:
[root@123schools.blogspot.in ~]# /etc/init.d/sshd restart

Now you will connect the server using custom ssh port number.
[root@123linuxschool.blogspot.in~]# ssh albin@123schools.blogspot.in -p 2220

No comments: