Change the default ssh port in CentOS
If you want to change the port and break through the port whitelist, but it does not work, record the process.
1. modify the configuration file
/Etc/ssh/sshd_config
#Port 22
Uncomment this line and add a new port
Port 22Port 1234
2. Restart sshd
There are several methods to choose from. If putty or another tool is used, if port 22 is always enabled, the ssh connection does not seem to be disconnected.
Method 1
/etc/init.d/sshd restart
Method 2
service sshd restart
Method 3 (Use this command on many vps instances)
systemctl restart sshd.service
Use systemctl to view service status
systemctl status sshd.service
Method 4: Start a new sshd process directly (as if not, it will be connected to closed)
/usr/sbin/sshd -p 2233
3. Check whether the netstat port is enabled.
net -an| grep [port]
If enabled, you can use the new port to log on.
ssh -p 1234 username@hostip