服务器(Ubuntu):
~/.ssh/authorized_keys
文件(在issue-user
):
- 一行只有一个公钥。没有多余的行!没有注释!
- 正确的用户/组所有者
- 644 权利
本地计算机(Windows 7):
git
与同一服务器上的用户一起工作- 不适用于
issue-user
- 密钥对匹配
运行后:ssh [email protected] -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
答案1
上述两个用户的密钥、父目录和/或主目录的权限存在问题。我的服务器 (Gentoo) 明确禁止公开可读密钥。
主页上的权限应为 o-rwx,保存密钥的 .ssh 目录上的权限应为 0700,密钥文件 authorized_keys 上的权限应为 0640。
SSHD 会将此类问题记录到 auth.log 中(取决于您的 syslog 配置)。