禁止IP或IP段访问SSH:hosts.allow 和 hosts.deny

Linux 系统/etc/目录下的文件hosts.allow和hosts.deny,可以允许或拒绝某个IP、IP段访问系统中使用了libwrap库的服务,如telnetd、ftpd、sshd等。
hosts.allow 和 hosts.deny
当远程请求到达本机时,会先检查/etc/hosts.allow如果有匹配就默认允许访问,并跳过/etc/hosts.deny文件,否则将接着去匹配/etc/hosts.deny,有匹配则拒绝访问。
SSH 访问权限设置
允许单个IP访问
折叠代码块
复制代码
1 | #/etc/hosts.allow 文件 |
允许多个IP访问
折叠代码块
复制代码
1 | #/etc/hosts.allow 文件 |
允许单个IP段访问
折叠代码块
复制代码
1 | #/etc/hosts.allow 文件 |
允许多个IP段访问
折叠代码块
复制代码
1 | #/etc/hosts.allow 文件 |
允许多个服务多个IP段
折叠代码块
复制代码
1 | #/etc/hosts.allow 文件 |
禁止所有服务与所有IP
折叠代码块
复制代码
1 | #/etc/hosts.deny 文件 |