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

标签 git ssh cmd ssh-keys

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

在调试时我发现在 bash 的情况下, ssh 正在检查 id_rsa key 但在 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).

请提出可能的情况。有人建议检查我的 key 的文件权限。两个 key 具有相同的文件权限,即 -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).

最佳答案

在文件中查看

/etc/ssh/ssh_config

它可能有一个 github 条目,告诉它 id 文件在哪里。将此更改为您希望它使用的那个

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

关于git - SSH - 通过 CMD 拒绝权限(无法验证 git@github.com),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18101701/

相关文章:

git clone,忽略一个目录

linux - 当用户从特定主机通过 SSH 登录时执行操作

batch-file - 带变量的批处理语句中缺少操作数错误

git - 如何获取自去年以来没有创建 pull 请求的分支列表?

git - 如何撤消上次提交

git - 为什么我的 .git/objects 文件夹是 175GB?

linux - cd 到目录和 su 到脚本中远程服务器上的特定用户

bash - 在 bash 上异步运行远程进程并在文件中获取其远程 pid、stdout+stderr 并退出代码

c++ - 在 Windows 上为 MinGW 编译的 C++ 程序是否适用于 Linux 上的 GNU 编译器?

c# - 在c#中运行cmd命令