為什麼 sshd 會查看不存在的公鑰檔案?

為什麼 sshd 會查看不存在的公鑰檔案?

為了讓 SSH 金鑰正常運作,我追蹤 sshd 授權日誌,並看到以下幾行:

debug1: test whether pkalg/pkblob are acceptable
debug1: temporarily_use_uid: 10144/10029 (e=0/0)
debug1: trying public key file /home/cklein/.ssh/authorized_keys
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 10144/10029 (e=0/0)
debug1: trying public key file /home/cklein/.ssh/authorized_keys2
debug1: restore_uid: 0/0
Failed publickey for cklein from 192.168.8.165 port 46583 ssh2

但如果我檢查/home/cklein/.ssh/目錄,它看起來像這樣:

$ ls -al /home/cklein/.ssh/
total 16
drwx------. 2 cklein infoarch 4096 May  3 16:39 .
drwxr-x--x. 9 cklein infoarch 4096 May  3 16:39 ..
-rw-------. 1 cklein infoarch  605 May  3 16:39 authorized_keys
-rw-r--r--. 1 cklein infoarch  226 Apr  4 16:11 known_hosts

我曾經authorized_keys2在該目錄中有一個文件,但將其刪除並重新啟動sshd。為什麼它仍然期望該文件存在?

另外,您對公鑰被拒絕的原因有任何猜測嗎?

答案1

.ssh/authorized_keys預設情況下,OpenSSH 伺服器會在和中尋找授權金鑰,除非您在 的設定檔中.ssh/authorized_keys2設定不同的值。AuthorizedKeysFile/etc/ssh/sshd_config

對於其餘的,我在目錄列表中看不到任何關鍵文件。您使用ssh-keygen命令生成了一個嗎?

相關內容