修改ssh端口

修改ssh端口

 

1.找到sshd配置文件

  /etc/ssh/sshd_config

2.修改sshd_config配置文件

  

 

 注:原配置文件 Port 22这行默认是注释的

添加一个新的端口最好把原来默认的22 端口打开

另按相同格式 指定一个新的端口

 

3.重启sshd 服务

systemctl restart sshd

 

4.查看sshd服务是否正常启动

systemctl status sshd

5.检查端口是否处于监听状态

  netstat -ntulp | grep sshd

 

 至此 ssh服务设置完成

6、设置防火墙策略

  ①.可以直接将防火墙全关闭了

    systemctl stop firewalld 

    systemctl disable firewalld

  ②.也可以只开10022宽口

  firewall-cmd --zone=public --add-port=10022/tcp --permanent

    查看10022端口是否添加到策略中

  firewall-cmd  --list-ports

7.关闭SeLinux

  vim /etc/selinux/config

 

   重启生效(若无法重启 可执行setenforce 0)

现在就可以使用XShell试着连接服务器了

ssh root@192.168.xx.xx   10022

 

posted @ 2020-12-16 10:31  梁永旺  阅读(3963)  评论(0编辑  收藏  举报