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

编辑于:2023年05月23日
禁止IP或IP段访问SSH:hosts.allow 和 hosts.deny

Linux 系统/etc/目录下的文件hosts.allowhosts.deny,可以允许或拒绝某个IP、IP段访问系统中使用了libwrap库的服务,如telnetdftpdsshd等。

hosts.allow 和 hosts.deny

当远程请求到达本机时,会先检查/etc/hosts.allow如果有匹配就默认允许访问,并跳过/etc/hosts.deny文件,否则将接着去匹配/etc/hosts.deny,有匹配则拒绝访问。

SSH 访问权限设置

允许单个IP访问

#/etc/hosts.allow 文件
sshd:192.168.0.0 
#/etc/hosts.deny 文件
sshd:ALL

允许多个IP访问

#/etc/hosts.allow 文件
sshd:192.168.0.0 , 192.168.0.1 #IP段
#/etc/hosts.deny 文件
sshd:ALL

允许单个IP段访问

#/etc/hosts.allow 文件
sshd:192.168.0.
#/etc/hosts.deny 文件
sshd:ALL

允许多个IP段访问

#/etc/hosts.allow 文件
sshd:192.168.0. , 192.168.1.
#/etc/hosts.deny 文件
sshd:ALL

允许多个服务多个IP段

#/etc/hosts.allow 文件
telnetd,sshd:192.168.1. , 192.168.2.
#/etc/hosts.deny 文件
sshd:ALL

禁止所有服务与所有IP

#/etc/hosts.deny 文件
all:all:deny

相关推荐

Centos7 防火墙 firewalld 的配置文件/开关/IP/端口

Centos7 防火墙 firewalld 的配置文件/开关/IP/端口

自Centos7起 ,系统防火墙由iptables改为了firewalld。本文聊一聊关于 firewalld 的一些常用操作,如配置文件所在目录、对端口和 IP 的限制、防火墙的开关等。 1.防火墙配置文件 1.1配置文件所在的目录 /usr/lib ...

Xshell支持SSH1 SSH2的安全终端模拟软件

Xshell支持SSH1 SSH2的安全终端模拟软件

1.Xshell简介 Xshell 是一个强大的安全终端模拟软件,它支持 SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 协议。Xshell 通过互联网到远程主机的安全连接以及它创新性的设计和特色帮助用户在复杂的网络环境 ...

暂无评论