1. 编辑sshd_config文件,记得提前做好备份。
vim /etc/ssh/sshd_config
2. 找到#Port 22,修改如下,
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
Port 22222
提示:22222端口不要和已有的服务端口相同,避免不必要的麻烦。
3. 执行重启命令
/etc/init.d/ssh restart
4. 新建一个终端测试,通过22222端口连接,如果成功则将Port 22删除。