小白xxx

导航

Centos 7 sshd白名单设置

/etc/hosts.allow 允许指定ip或ip网段连接服务器

/etc/hosts.deny 禁止指定ip或ip网段连接服务器

当两个配置文件中同时存在相同对象时,allow生效;

故,可通过配置两个文档来实现白名单的目的;

1、/etc/hosts.deny 中配置阻止所有连接

vim /etc/hosts.deny 中,sshd:All //阻止全部访问

2、/etc/hosts.allow 中配置允许连接的ip或网段

vim /etc/hosts.allow 中,sshd:192.168.0.1,192.168.0.51 //允许192.168.0.1和192.168.0.51登录 -----------多个ip需要用,隔开

根据两个文件的优先级判断。则可得出,alliw中指定的ip可以连接,除次以外的都无法连接。故而达到白名单的目的。

posted on 2021-05-31 11:03  清汤挂面X  阅读(984)  评论(0)    收藏  举报