SSH - 通过CMD拒绝(无法验证git@github.com)权限 [英] SSH - Permission denied (cannot authenticate git@github.com) via CMD

查看:1651
本文介绍了SSH - 通过CMD拒绝(无法验证git@github.com)权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows XP。我正面临weired问题,当我尝试连接到git@github.com使用bash ssh -v git@github.com
我可以成功连接,但当我尝试通过cmd在同一台机器上连接我收到消息权限被拒绝。在调试时,我发现在bash的情况下, ssh正在检查id_rsa键,但是在cmd的情况下,SSH只是检查github_rsa。甚至没有尝试检查id_rsa。下面是日志。

  OpenSSH_4.6p1,OpenSSL 0.9.8e 2007年2月23日
debug1: etc / ssh / ssh_config
debug1:为*
应用选项debug1:应用github.com的选项
debug1:连接到github.com [204.232.175.90]端口22.
debug1:建立连接。
debug1:identity file / c / Documents和Settings / username / .ssh / github_rsa type 1
debug1:远程协议版本2.0,远程软件版本OpenSSH_5.5p1 Debia n-6 + squeeze1 + github12
debug1:match:OpenSSH_5.5p1 Debian-6 + squeeze1 + github12 pat OpenSSH *
debug1:为协议2.0启用兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_4.6
警告:将github.com,204.232.175.90(RSA)永久添加到已知主机列表。
debug1:ssh_rsa_verify:签名正确
debug1:可以继续的认证:publickey
debug1:下一个认证方法:publickey
debug1:提供公钥:/ c / Documents and Settings / username / .ssh / github_rsa
debug1:服务器接受密钥:pkalg ssh-rsa blen 277
debug1:read PEM私钥done:type RSA
debug1:认证可以继续:publickey
debug1:没有更多的身份验证方法试试。
权限被拒绝(publickey)。

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



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

  OpenSSH_4.6p1,OpenSSL 0.9.8e 2007年2月23日
debug1:读取配置数据/ etc / ssh / ssh_config
debug1:应用*
的选项debug1:应用github.com的选项
debug1:连接到github.com [204.232.175.90]端口22.
debug1:建立连接。
debug1:identity file / c / Documents和Settings / username / .ssh / github_rsa type 1
debug1:identity file / c / Documents和Settings / username / .ssh / id_rsa type 1
debug1:远程协议版本2.0,远程软件版本OpenSSH_5.5p1 Debian-6 + squeeze1 + github12
debug1:match:OpenSSH_5.5p1 Debian-6 + squeeze1 + github12 pat OpenSSH *
debug1:对于协议2.0
debug1:本地版本字符串SSH-2.0-OpenSSH_4.6
警告:将github.com,204.232.175.90(RSA)永久添加到已知主机列表。
debug1:ssh_rsa_verify:签名正确
debug1:可以继续的认证:publickey
debug1:下一个认证方法:publickey
debug1:提供公钥:/ c / Documents and Settings / username / .ssh / github_rsa
debug1:服务器接受密钥:pkalg ssh-rsa blen 277
debug1:read PEM私钥done:type RSA
debug1:认证可以继续:publickey
debug1:提供公钥:/ c / Documents和Settings / username / .ssh / id_rsa
debug1:可以继续的身份验证:publickey
debug1:没有更多的身份验证方法可以尝试。
权限被拒绝(publickey)。


解决方案


文件权限,即-rw-r - r -


你实际上让登录系统的人读取你的id_rsa私钥,这是不好的。实际上,您的id_rsa键应该有600(-rw -------)权限,它是通过发出 chmod 600 id_rsa 命令完成的。此外,还要检查.ssh文件夹权限,并将它们设置为700


I'm on windows XP. I'm facing weired problem as when I try to connect to git@github.com using bash ssh -v git@github.com i'm able to connect successfully but when i am trying to connect via cmd on same machine I'm getting message permission denied.

On debugging I found that in case of bash, ssh is checking id_rsa key but in case of cmd SSH is just checking github_rsa. Not even trying to check id_rsa. Below are the logs.

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).

Please suggest what could be the possible case. Some suggests to check the file permissions on my key. Both keys have same file permissions i.e. -rw-r--r--

Below is the updated code after making changes mentioned by @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).

解决方案

Both keys have same file permissions i.e. -rw-r--r--

You actually let people, logged on your system, read your id_rsa private key, which is not good. Actually, your id_rsa key should have 600 (-rw-------) permission, and it's done by issuing chmod 600 id_rsa command. Also, check .ssh folder permissions too and set them to 700

这篇关于SSH - 通过CMD拒绝(无法验证git@github.com)权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆