ein*_*lum 7 ssh logging authentication public-key
我使用 OpenSSH 6.9p1(在 Lubuntu 上)作为我的 SSH 服务器。当尝试连接到它时(在 Cygwin 中使用 SSH 客户端),尽管我正确生成了我的密钥,将它们放在服务器上的授权密钥文件中,检查权限等,但我仍然被恢复为密码身份验证。
所以,我看看/var/log/auth.log服务器说了什么。我发现这个:
Nov 1 09:50:10 er-thinkpad sshd[16148]: Accepted password for joeuser from 192.168.2.6 port 53325 ssh2
Nov 1 09:50:10 er-thinkpad sshd[16148]: pam_unix(sshd:session): session opened for user joeuser by (uid=0)
Nov 1 09:50:10 er-thinkpad systemd-logind[590]: New session 497 of user joeuser.
Run Code Online (Sandbox Code Playgroud)
...在第一行之前没有关于公钥认证失败的内容。好的,让我们增加详细程度吧。所以我LogLevel从INFO改为VERBOSE并再试一次。现在我得到:
Nov 1 09:53:12 er-thinkpad sshd[16269]: Connection from 192.168.2.6 port 53349 on 192.168.2.2 port 22
Nov 1 09:53:12 er-thinkpad sshd[16269]: Failed publickey for joeuser from 192.168.2.6 port 53349 ssh2: RSA SHA256:removedthis
Nov 1 09:53:12 er-thinkpad sshd[16269]: Failed publickey for joeuser from 192.168.2.6 port 53349 ssh2: ECDSA SHA256:removedthis
Nov 1 09:53:15 er-thinkpad sshd[16269]: Accepted password for joeuser from 192.168.2.6 port 53349 ssh2
Nov 1 09:53:15 er-thinkpad sshd[16269]: pam_unix(sshd:session): session opened for user joeuser by (uid=0)
Nov 1 09:53:15 er-thinkpad systemd-logind[590]: New session 499 of user joeuser.
Nov 1 09:53:15 er-thinkpad sshd[16269]: User child is on pid 16271
Nov 1 09:53:15 er-thinkpad sshd[16271]: Starting session: shell on pts/5 for joeuser from 192.168.2.6 port 53349
Run Code Online (Sandbox Code Playgroud)
太好了,它失败了,但为什么会失败?我怎样才能让 sshd 告诉我呢?
PS - 只是让你知道,这是客户看到的:
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/joeuser/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Skipping ssh-dss key /home/joeuser/.ssh/id_dsa for not in PubkeyAcceptedKeyTypes
debug1: Offering ECDSA public key: /home/joeuser/.ssh/id_ecdsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/joeuser/.ssh/id_ed25519
debug1: Next authentication method: password
Run Code Online (Sandbox Code Playgroud)
在服务器端,将日志级别设置为DEBUG3. 在客户端,使用-vvv选项连接(它也为您DEBUG3提供客户端)。