如何设置OpenSSH每用户身份验证方法?


9

我希望能够让一组用户使用公钥身份验证进行身份验证,而其他用户则使用密码身份验证。

Linux上的OpenSSH是否可能?如果是这样,我该怎么办?

看完之后/etc/ssh/sshd_config,似乎我仅限于启用密钥认证或使用PAM。

Answers:


15

Match指令(描述man sshd_config)允许在sshd服务器的一个实例,以指定为不同的用户不同的认证方法。作为枚举单个用户和组的奖励,它还允许通过通配符选择它们。

Match Group wheel                # for users from group wheel:
PubkeyAuthentication
Match Group !wheel,*             # for other users:
PasswordAuthentication
# caution: don't add directives here - they will be caught by "Match" block
# (end of file /etc/ssh/sshd_config)

0

可以运行两个不同的OpenSSH实例。一个配置为PasswordAuthentication,另一个配置为PubkeyAuthentication(每个绑定到一个不同的地址)。然后,AllowGroups将使用配置指令来控制哪些组可以使用哪个服务器。

但是我可能会误解这个问题,因为您说“这是PAM或公钥身份验证”。两者可以同时启用。它们不是互斥的。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.