How to change SSH port from 22 to any other port through Putty in Linux Server

How to change SSH port from 22 to any other port through Putty in Linux Server and why it is necessary to change the port

 

Usually when a Linux server is delivered by data center or by default it is running under Port 22 for SSH which is really dangerous to keep with this port 22 open.

Because if your port 22 will remain open for ssh then i am making you sure that you have given a full way to Server Hacker to hack your server from the root level, because it is very common that in linius servers port 22 opened by default so a hacker can easily access your server through this port, so it is highly recomended to change your SSH port from 22 to some one other, a port which is not being used for any other purpose.

Now i will tell you how you can change your SSH port yourself quite easily through command line putty.

Login to your server using your root credentials, once you get login, use below given commands

cd /etc/ssh

sudo nano sshd_config

Here you must find the line #port 22 then edit 22 to any other port like 2001 (remove the # (hash tag) to allow the changes take effect)

To exit out of the Nano editor, hit CRTL + X

Hit Y to save Changes

Type following command “service sshd restart



=======================


You may also use below other commands if the above way will not work for you

 

Login through SSH putty and use following command
vi /etc/ssh/sshd_config


Change the line “#Port 22? to “Port 2000?
In place of 2000 you may place any other number of port so that in the future you can use that port for ssh then type this command “service sshd restart” without quotes.

After making these changes if you find any issue you may revert your setting by below give URL.

http://IP:2086/scripts2/doautofixer?autofix=safesshrestart

Replace “IP” with the IP address of your server, it will revert your sshd port to 22.

 

Add a Comment

*