Announcement

Collapse
No announcement yet.

How to change the default SSH port on my CentOS server?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change the default SSH port on my CentOS server?

    To change the default SSH port on your server, log in to SSH and type vi /etc/ssh/sshd_config. And using your arrow keys, go to the line which says “Port 22” and press i on your keyboard (this allows you to edit the current line). Then edit the number to whatever you want the SSH listening port to be, just make sure you do not change it to a port which is reserved for another service – see the full list to be sure. Once you've changed the SSH port number on the line, press Esc on your keyboard and then type :wq which writes to (saves) the configuration file and quits the text editor.

    Once you've done this, you need to restart the SSH Daemon by executing service sshd restart.

    Finally, you need to make sure the new port for SSH is open in the firewall. In WHM, find the ConfigServer Security&Firewall and open Firewall Configuration. Add the new port for SSH in the TCP_IN field and then save the changes by pressing the Change button at the bottom of the page. After which, you will need to restart csf and lfd, and you will be prompted to do this by pressing the Restart csf+lfd button on the last page.

    Hope this helps.
Working...
X