Ssh
無法使用 SSH-RSA 密鑰登錄
這篇文章關注這個問題:身份驗證被拒絕:文件 /var/git/.ssh/authorized_keys 的所有權或模式錯誤。
那裡暴露的問題已解決(關於文件
.ssh
夾的文件模式。但是另一個問題仍然存在,所以我創建了一個新問題:
當我嘗試登錄(使用詳細選項)時,一切似乎都可以正常工作,但最後,發生了以下情況:
debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/remi/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password debug1: Trying private key: /home/remi/.ssh/id_dsa debug1: Trying private key: /home/remi/.ssh/id_ecdsa debug1: Trying private key: /home/remi/.ssh/id_ed25519 debug2: we did not send a packet, disable method debug1: Next authentication method: password
我不明白,因為這些行對我來說似乎是無意義的:
we sent a publickey packet, wait for reply
we did not send a packet, disable method
如果目標主機上使用者*主目錄的文件模式設置不正確,則會出現此行為。*不只是 .ssh 目錄的模式需要正確設置!
ssh 到主機並提供您的登錄密碼,然後
chmod 755 ~ logout
然後再次 ssh 並假設您已正確設置其他所有內容(請參閱其他答案),您應該能夠登錄。
這是主目錄完全打開時的樣子 (777)。請注意,它不會嘗試 rsa 密鑰:
ssh -v user@host ... debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/iwoolf/.ssh/id_rsa debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Trying private key: /home/iwoolf/.ssh/id_dsa debug1: Trying private key: /home/iwoolf/.ssh/id_ecdsa debug1: Trying private key: /home/iwoolf/.ssh/id_ed25519 debug1: Next authentication method: password ...
然後正確設置主目錄權限(755):
ssh -v user@host ... debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/iwoolf/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 279 debug1: Authentication succeeded (publickey).