Linux修改ssh端口

1、登录服务器,打开sshd_config文件

vim /etc/ssh/sshd_config


2、找到#Port 22,默认是注释掉的,先把前面的#号去掉,再插入一行设置成你想要的端口号,注意不要跟现有端口号重复

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.

Port 22
Port 10086


3、保存后退出,执行重启命令

service sshd restart


4、新开一个终端窗口测试10086端口是否可以正常连接服务器,如果成功则将Port 22删除,之所以先设置成两个端口,测试成功后再关闭一个端口,是为了方式在修改conf的过程中,万一出现掉线、断网、误操作等未知情况时候,还能通过另外一个端口连接上去调试以免发生连接不上必须派人去机房,导致问题更加复杂麻烦。

你可能感兴趣的:(Linux修改ssh端口)