CentOS7关于限制IP通过ssh登陆

编辑/etc/hosts.allow配置文件

vi /etc/hosts.allow

sshd:ALL:allow #表示允许所有ip连接

sshd:192.168.3.2:allow #仅允许此IP连接

sshd:192.168.3.*:allow #允许.3网段的所有IP连接

再配合/etc/hosts.deny配置文件

vi /etc/hosts.deny

sshd:ALL:deny

以上配置表示除了hosts.allow中配置的地址可以连接,其他所有的IP都无法通过ssh连接

还可以通过直接配置hosts.deny来拒绝某个IP进行连接

vi /etc/hosts.deny

sshd:192.168.3.2:deny

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

Scroll to Top