为什么我的 hosts.deny 在 OSX 10.8 上不起作用?

Len*_*oyt 2 ssh mac-osx-server mac-osx denyhosts hosts-file

为了测试它,我将这四行添加到我的/etc/hosts.deny文件中:

# /etc/hosts.deny
ssh-agent:ALL
sshd:ALL
 
Run Code Online (Sandbox Code Playgroud)

我等了一段时间,然后尝试通过 ssh 访问环回 IP 地址。但我仍然得到这个:

$ ssh root@localhost
Password: ?
Run Code Online (Sandbox Code Playgroud)

我可以访问它。我什至尝试添加明确拒绝从 127.0.0.1 访问的条目。

ser*_*ren 5

Tcpwrappers(使用 hosts.deny 中的条目)已从 OS X 10.8 (Mountain Lion) 中删除,因此 sshd 不再关注该文件中的内容。您可以改用数据包过滤器,或通过 MacPorts 安装 libwrap 并重新编译 sshd。

运行“ man pfctl ”以获取有关如何控制和配置规则的详细信息。

关于如何在此处使用pfctl有一个很好的介绍: A Cheat Sheet For Using pf in OS X Lion and Up