我知道,我可以禁用root用户的明文密码的SSHauthentication(使用PermitRootLogin ),并为所有其他用户启用它。 但我需要为某些用户列表禁用文本密码(并且只保留它们的公钥validation)。 对于那些没有列入清单的人,我也需要启用密码authentication。
那么,我如何为不同的用户调整不同的SSH策略呢? 在sshd_config中我只find了两个参数:
PermitRootLogin without-password # disable text password for root PasswordAuthentication yes # enable it for all other users
我想要一些字典式的configuration,例如:
user1Auth without-password user2Auth without-password user3Auth yes ...
PS我的操作系统是Ubuntu 14.04。
您可以使用Match User或Match Group指令:
Match Group usergroup PasswordAuthentication no
如果你不想使用组,你可以指定每个用户:
Match User user1,user2 PasswordAuthentcation yes Match User user3 PasswordAuthentication no
我的首选是不要直接给用户分配权限(不pipe系统),所以我总是使用组。 这也带来了好处,您可以更改组成员资格,而无需重新启动sshd。
NB。 此configuration行必须写在/etc/sshd_config中所有其他configuration下。