如何使MSysGit使用非默认密钥文件名?

时间:2013-03-07 23:42:04

标签: git connection msysgit msys

为了在多个GitHub帐户中使用多个密钥(在this操作方法之后),我想首先让我的本地系统使用名称不是默认id_rsa的密钥文件。< / p>

我创建了一个密钥对id_rsa_user&amp; id_rsa_user.pub并将私钥部分添加到SSH Authentification代理,将公钥部分添加到GitHub(“Generating SSH Keys”)。

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

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

最后,我将项目的远程网址从git@github.com:user/project.git更改为git@github.com-user:user/project.git(s。评论为this操作方法)。

现在它正在开发我的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 '.'...

enter image description here

fatal: The remote end hung up unexpectedly

有人有任何想法,如何解决这个问题?

THX

编辑:

添加信息 - 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

1 个答案:

答案 0 :(得分:0)

检查GIT_SSH的环境变量。如果已设置,则取消设置以停止为SSH客户端使用PuTTY。您正在尝试使用openssh配置选项,因此您希望使用msysgit附带的openssh。