Ssh

SSH 不適用於我的使用者密鑰,但適用於另一個使用者

  • September 19, 2013

伺服器(Ubuntu):

~/.ssh/authorized_keys文件(上issue-user):

  • 一行上只有一個公鑰。沒有多餘的線條!暫無評論!
  • 正確的使用者/組所有者
  • 644 權利

本地機器(Windows 7):

  • git同一伺服器上的使用者一起工作
  • 不適用於issue-user
  • 密鑰對匹配

執行後ssh issue-user@domain.com -vvv

debug2: key: /c/***/***/.ssh/identity (0x0)
debug2: key: /c/***/***/.ssh/id_rsa (0x0)
debug2: key: /c/***/***/.ssh/id_dsa (0x0)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/***/***/.ssh/identity
debug3: no such identity: /c/***/***/.ssh/identity
debug1: Trying private key: /c/***/***/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug3: sign_and_send_pubkey
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /c/***/***/.ssh/id_dsa
debug3: no such identity: /c/***/***/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

id_rsa密鑰文件肯定在那裡:/c/***/***/.ssh/id_rsa

上述兩個使用者的密鑰、父目錄和/或主目錄的權限存在問題。我的伺服器(Gentoo)明確禁止公開可讀的密鑰。

home 的權限應該是 o-rwx,.ssh 目錄持有密鑰的權限應該是 0700,密鑰文件的授權密鑰權限應該是 0640。

SSHD 會將此類問題記錄到 auth.log 中(取決於您的系統日誌配置)。

引用自:https://serverfault.com/questions/540152