Steps to modify the sshd default port

  • 2020-05-07 20:48:37
  • OfStack

The specific steps are as follows:

1. Modify the configuration file


vi /etc/ssh/sshd_config

Find "Port 22", remove the comment and change to a new port number, for example:


Port 22342

Then save exit, 1 must remember this port number, or 1 exit the current client will not connect.

2 to restart sshd


/etc/init.d/sshd restart

The new port will take effect, but the current connection will not be disconnected

Verify that the new port is open


telnet 1.2.3.4 22342

The prompt "SSH-2.0-OpenSSH_x.x" indicates that it is in effect; If the prompt "connection to host cannot be opened, connection failed on port xxxxx: connection failed" indicates that the modification failed, and go back to find the reason.


Related articles: