概述
在企业中,服务器上只允许通道机IP以root用户登录,要实现这种功能,需要在服务器上设置某一或某些IP登录SSH,并拒绝其他所有IP登录,同时修改SSH端口。有两种方法:
方法一. 修改sshd_config
[root@baihu ~]# vim /etc/ssh/sshd_config
添加 AllowUsers Root@10.132.4.*(通道机IP)
...
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#Port 22
Port 3903
AllowUsers Root@10.132.4.*
#PermitRootLogin no
#AddressFamily any
#ListenAddress 0.0.0.0
...
注释掉Port 22,并修改为规定的端口号,这里我们用的是3903(修改SSH端口)
重启服务:
[root@baihu ~]# systemctl restart sshd
生效。通道机10.132.4.以外的IP将无法登录。
方法二修改hosts.*
修改/etc/hosts.allow,添加 sshd:10.132.4.*:allow
[root@baihu ~]# vim /etc/hosts.allow
#
# hosts.allow This file contains access rules which are used to
# allow or deny conne

最低0.47元/天 解锁文章
1116

被折叠的 条评论
为什么被折叠?



