经过对比,这俩用户下的私钥是一模一样的,.ssh和id_rsa的权限也都是正确的。
用ssh的-v参数,看到这两个用户的公钥认证的输出信息稍微有所不同。用户A的:
debug1: Next authentication method: publickey
debug1: Trying private key: /home/userA/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug2: we sent a publickey packet, wait for reply
debug1: Authentication succeeded (publickey).
用户B的:
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/userB/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp ef:a2:55:bc:86:1f:0a:48:e1:45:fc:b5:da:ca:70:e0
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /home/userB/.ssh/id_dsa
用户A开始打出的是:Trying private key,而用户B打出的是:Offering RSA public key。
最后实在看不出配置哪里有不同,就把用户B下面不相关的公钥id_rsa.pub移出去,然后认证成功了。因为我认为公钥不重要,认证看的是私钥,所以没有管那个无效的公钥。结果罪魁祸首竟然就是这个无关的公钥。
看来OpenSSH如果看到公钥文件名,则从公钥检查起,而这样不配对的私钥就认证失败了。而如果只放私钥,反而会成功。从这个文件里面也能验证这一点。
没有评论:
发表评论