Monday, March 26, 2012

How to Change the SSH Port in CentOS

By Default CentOS uses SSH Port Number 22 for security reasons it is recommended to change the Port Number:

Procedure : 

1.You need to open SSHD config file using nano.
2.Thats your SSHD config file. On that there will be line called
3.Restart SSH daemon to apply changes in running configuration
nano /etc/ssh/sshd_config
You will see the port number is commented by default that shows it is 22 by default
#Port 22
So
You just need to uncomment #Port 22 and replace 22 with some other number like 2020 etc.
Port 2020 
Now your SSH port is 2020
You can change the number 22 to whatever port that you like. After you done hit Ctrl+O key on keyboard to write the chnages in to the file and then Ctrl+X to exit the text editor.
Next time when you will try to connect to your linux server via ssh client. then you must use new port number instead of default 22.

On CentOS run
service sshd restart
On debian or Ubuntu run
restart ssh
Then you will be immediately logged out from current SSH session because port changed.

No comments:

Post a Comment