Sunday, 21 September 2014

How to Change SSH Port Number


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@amir~]# 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 2221

After implementing your required changes, save and quit from the configuration file and restart the ssh service. Service restart as shown below:

[root@amir ~]# service sshd restart

[root@amir ~]# chkconfig sshd on

Now you will connect the server using custom ssh port number.

[root@amir ~]# ssh rumee@server.amir.com -p 2221

No comments:

Post a Comment