SSH - 通过CMD拒绝权限(无法验证git@github.com)

时间:2013-08-07 11:02:45

标签: git ssh cmd ssh-keys

我在Windows XP上。当我尝试使用bash连接到git@github.com ssh -v git@github.com 时,我面临着问题 我能够成功连接,但当我尝试通过同一台机器上的cmd连接时,我收到消息权限被拒绝。

在调试时我发现在bash的情况下, ssh正在检查id_rsa密钥,但是在cmd的情况下,SSH只是检查github_rsa。甚至没有尝试检查id_rsa。以下是日志。

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for github.com
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /c/Documents and Settings/username/.ssh/github_rsa type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debia n-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Documents and Settings/username/.ssh/github_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

请建议可能的情况。有人建议检查我的密钥上的文件权限。两个密钥都具有相同的文件权限,即 -rw-r - r -

以下是@naomi提到的更改后的更新代码

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for github.com
debug1: Connecting to github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /c/Documents and Settings/username/.ssh/github_rsa type 1
debug1: identity file /c/Documents and Settings/username/.ssh/id_rsa type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Documents and Settings/username/.ssh/github_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: Offering public key: /c/Documents and Settings/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

2 个答案:

答案 0 :(得分:0)

查看文件

/etc/ssh/ssh_config

它可能在github中有一个条目告诉它id文件的位置。将其更改为您要使用的那个

如果这不起作用,您可以随时将id_rsa复制到github_rsa ...

答案 1 :(得分:0)

  

两个密钥都具有相同的文件权限,即-rw-r - r -

您实际上让登录系统的人员读取了您的id_rsa私钥,这并不好。实际上,你的id_rsa密钥应该有600(-rw -------)权限,并且通过发出 chmod 600 id_rsa 命令来完成。另外,也请检查.ssh文件夹权限并将其设置为700