如何仅从某些IP地址允许SSH密码validation?

我想只允许来自某个子网的SSH密码validation。 我在/etc/ssh/sshd_config看到了全局禁止它的选项:

 # Change to no to disable tunnelled clear text passwords #PasswordAuthentication yes 

有没有办法将此配置应用于选定范围的IP地址?

/etc/ssh/sshd_config 末尾使用Match块:

 # Global settings … PasswordAuthentication no … # Settings that override the global settings for matching IP addresses only Match address 192.0.2.0/24 PasswordAuthentication yes 

然后告诉sshd服务重新加载其配置:

 service ssh reload 

你可以加:

 AllowUsers user1@192.168.*.*, user2@192.168.*.* 

这会更改默认行为,实际上拒绝所有主机中的所有其他用户。 OpenSsh 5.1及更高版本上可用的匹配块。