首页 > 其他分享 >ssh修改端口号-添加白名单-禁止root用户远程登录

ssh修改端口号-添加白名单-禁止root用户远程登录

时间:2023-02-25 15:22:51浏览次数:35  
标签:sshd config etc ssh allow 白名单 root 端口号

sshd限制

1.修改ssh端口
vim /etc/ssh/sshd_config
#Port 22
Port 20199  #指定端口
Port 20100
#ListenAddress 0.0.0.0
#ListenAddress ::

2.添加ssh白名单
[root@small ~]# vim /etc/hosts.allow
sshd:10.10.10.
sshd:10.241.107.85:allow
sshd:10.28.234.124:allow
sshd:172.16.2.30:allow  


3. 设置禁止root用户远程登录
解决办法:需要修改 /etc/ssh/sshd_config 配置,允许登录

1.编辑配置文件
   命令:vi /etc/ssh/sshd_config
2.文件中找到PermitRootLogin
  #PermitRootLogin without-password
  将#去掉,without-password改为yes
  PermitRootLogin yes
3.退出并保存,重启ssh
  命令:service sshd restart


4. ssh连接失败
[root@ZJHZ-SERVICE-A1 mone]# ssh [email protected] -p 20199
ssh_exchange_identification: read: Connection reset by peer
解决:
vi /etc/hosts.allow
追加:
sshd: ALL
重启ssh就ok了
service sshd restart

标签:sshd,config,etc,ssh,allow,白名单,root,端口号
From: https://www.cnblogs.com/anslinux/p/17154481.html

相关文章