Linux修改ssh端口

246 阅读1分钟

Linux修改ssh端口

VPS 云服务器环境:CentOS 7.9

工具:Xshell7

//在sshd_config中添加端口

vi /etc/ssh/sshd_config   

image.png

//重启ssh服务

systemctl restart sshd

image.png

//添加防火墙端口的前提是防火墙要打开

systemctl start firewalld 

image.png

//向防火墙添加一个可开放的例外

firewall-cmd --zone=public --add-port="添加的端口"/tcp --permanent 

image.png

//出现yes表示防火墙放行成功

firewall-cmd --permanent --query-port="添加的端口"/tcp     

image.png

//重启加载防火墙

firewall-cmd –reload

image.png

//查看防火墙放行的端口

firewall-cmd --zone=public --list-ports 

image.png