Linux SSH限制 IP 登录

Linux SSH限制 IP 登录

说明:这里的IP是指客户端IP,不是服务器IP,下面的例子使用了hosts.allow文件的配置方式

Linux 服务器通过设置/etc/hosts.allow/etc/hosts.deny这个两个文件,hosts.allow许可大于hosts.deny可以限制或者允许某个或者某段IP地址远程 SSH 登录服务器,方法比较简单,且设置后立即生效,不需要重启SSHD服务,具体如下:

/etc/hosts.allow添加:

sshd:10.0.0.14:allow  #允许 10.0.0.14 这个IP地址SSH登录
sshd:10.0.10.:allow #允许 10.0.10.0/24 这段IP地址的用户登录.

/etc/hosts.deny 添加:

sshd:ALL #拒绝全部IP

这样就会限制其他IP登录。

发表回复 0

Your email address will not be published. Required fields are marked *