问题原文
原帖链接 · Prabhu · CC BY-SA 3.0
I have the need of having users logging in to a CentOS system with different authentication methods. Some using password and others using public key.
I followed the methods mentioned here: How can I setup OpenSSH per-user authentication methods?
However, I am not successful in having successful password based login.
In the sshd_config file, I have:
AuthenticationMethods keyboard-interactive,publickey
PasswordAuthentication no
Match User newton
PasswordAuthentication yes
Match all
Update: I see that the issue is only when I have 2FA enabled with google authentication and I have the line:
AuthenticationMethods keyboard-interactive,publickey
Though for the user newton, I have set password authentication I see the following error:
[root@localhost]# ssh [email omitted]
Permission denied (publickey).
Any suggestions are appreciated.
已采纳解答
原帖链接 · Jakuje · CC BY-SA 3.0
Although @Tolsadus answer probably points to the correct solution, it does not answer the question clearly.
In short, manual page for ssh_config is a good start to understand how the config parser in ssh works (the same rules apply for sshd_config):
For each parameter, the first obtained value will be used
This means that your example will set PasswordAuthentication to no for all users and for newton user will not overwrite it (because it is already set). To work it around, you should set the default values in the Match block. This will have the expected effect on newton user:
Match User newton
PasswordAuthentication yes
Match all
PasswordAuthentication no
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
