0

为了对多个 GitHub 帐户使用多个密钥(在操作指南之后),我首先要让我的本地系统使用命名为 default 以外的密钥文件id_rsa

我创建了一个密钥对id_rsa_user&id_rsa_user.pub并将私钥部分添加到 SSH 身份验证代理,并将公钥部分添加到 GitHub(“生成 SSH 密钥”)。

然后我~/.ssh/config用这个内容创建了文件:

#user account
Host github.com-user
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_user

最后,我将项目的远程 URL 从更改git@github.com:user/project.git为(s.对此git@github.com-user:user/project.git操作方法的注释)。

现在它正在我的 VirtualBox-VM (Debian) 和 TortoiseGit 上运行。但是 MSysGit 抛出一个错误:

(试图推送 git@github.com:user/project.git)

***@**** /path/to/to/project (master)
$ git push
fatal: The remote end hung up unexpectedly

(试图克隆 git@github.com-user:user/project.git)

***@**** /path/to/to/project (master)
$ git clone git@github.com-user:user/project.git .
Cloning into '.'...
fatal: The remote end hung up unexpectedly

(试图克隆 git@github.com:user/project.git ):

***@**** /path/to/to/project (master)
$ git clone git@github.com:user/project.git .
Cloning into '.'...

在此处输入图像描述

fatal: The remote end hung up unexpectedly

有人知道如何解决这个问题吗?

谢谢

编辑:

添加信息——ssh -v git@github.com-user输出:

***@**** ~/Desktop/test
$ ssh -v git@github.com-user
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/avex/.ssh/config
debug1: Applying options for github.com-user
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
debug1: identity file /c/Users/avex/.ssh/id_rsa_user type 1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github8
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github8 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/avex/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/avex/.ssh/id_rsa_user
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Remote: Forced command: gerve user 8d:25:62:90:20:4e:89:99:85:42:2c:d6:0a:03:66:dc
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command: gerve user 8d:25:62:90:20:4e:89:99:85:42:2c:d6:0a:03:66:dc
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi user! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
debug1: Transferred: stdin 0, stdout 0, stderr 34 bytes in 0.6 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 61.2
debug1: Exit status 1
4

1 回答 1

0

检查您的环境变量以获取GIT_SSH. 如果已设置,则取消设置以停止将 PuTTY 用于您的 SSH 客户端。您正在尝试使用 openssh 配置选项,因此您想使用 msysgit 中包含的 openssh。

于 2013-03-08T01:12:47.970 回答