我需要用户以不同的身份validation方法login到CentOS系统。 一些使用密码和其他人使用公共密钥。
我遵循这里提到的方法: 如何设置OpenSSH每用户身份validation方法?
但是,我没有成功的基于密码的login成功。
在sshd_config文件中,我有:
AuthenticationMethods keyboard-interactive,publickey PasswordAuthentication no Match User newton PasswordAuthentication yes Match all
更新:我看到这个问题是只有当我有谷歌身份validation2FA启用,我有行:
AuthenticationMethods keyboard-interactive,publickey
虽然对于用户牛顿,我已经设置了密码authentication,我看到以下错误:
[root@localhost]# ssh [email protected] Permission denied (publickey).
任何build议表示赞赏。
尽pipe@Tolsadus的回答可能指出了正确的解决scheme,但它并没有清楚地回答这个问题。
简而言之, ssh_config手册页是了解ssh中的configurationparsing器是如何工作的(同样的规则适用于sshd_config ):
对于每个参数,将使用第一个获得的值
这意味着您的示例将为所有用户将PasswordAuthentication设置为no ,对于newton用户不会覆盖它(因为它已经设置)。 为了解决这个问题,你应该在Match块中设置默认值。 这将对newton用户产生预期的影响:
Match User newton PasswordAuthentication yes Match all PasswordAuthentication no
完美的解释如何使用/etc/ssh/sshd_config的匹配选项
在你的情况下,你应该这样做“真实”的世界的例子https://gist.github.com/kjellski/5940875
您可以find与地址相匹配的地址,也可以查找被评论的用户。
编辑/更新
@Jakuje正确地回答了这个问题,比我的方式更精确。