修改linux的ssh默认端口号22的方法

发布时间:2020年10月28日 阅读:382 次

一、关闭firewall:

service firewalld stop

systemctl disable firewalld.service #禁止firewall开机启动

二、修改配置文件

vi /etc/ssh/sshd_config

找到#Port 22

修改为自己要使用的端口号:Port 26000

然后 :wq 退出保存

( 备注:建议Port 22端口暂时不要删除 如果新增的端口能使用再删除Port 22这行)


三、重启ssh服务 systemctl restart sshd


如果还要设置防火墙,配置:vi /etc/sysconfig/iptables

启用26000端口:/etc/init.d/iptables restart

 

四、如果要显示固定IP才能登陆:

1.修改 /etc/hosts.deny, 加入一行sshd:ALL   --#意思是任何ip都不能登陆

2.然后修改:/etc/hosts.allow,在其中进行如下设置:sshd:192.168.0.241  --#意思是只允许192.168.0.241登陆


Tag:
相关文章

发表评论: