There was a problem loading the comments.

Changing The SSH Port

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

It is recommended to change default SSH port (22) of Linux Server as part of security measure to harden your server. You can accomplish this by following below steps:

 

1) Login to the server via SSH as root:

ssh root@hostname/IP

where hostname/IP should be the host name / IP address to connect to the server.

2) We will need to edit sshd_config file and hence it is recommended that you backup original file before proceeding:

cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup

3) Open sshd_config in your favorite text editor (vim / nano):

vi /etc/ssh/sshd_config

-OR-

nano /etc/ssh/sshd_config

4) Navigate to line mentioning #Port (which is currently commended out with a # sign). Remove # and replace port 22 with your preferred new port # (eg 2220).

#Port 22 should be replaced with

Port 2220

5) Save your changes and close the sshd_config file

6) Important - If you have firewall running on the server, you will need to edit the rules and allow newly entered port # in firewall exception list.

7) Restart sshd service by running /etc/init.d/sshd restart


Share via
Thank you for your feedback on this article.

Related Articles

© Softsys Hosting