2013-03-07 52 views
0

为了使用多个密钥用于多个GitHub的帐户(后this如何做),我想第一个拿到我的本地系统是比默认id_rsa命名的其他关键文件的工作。如何使MSysGit使用非默认密钥文件名工作?

我创建的密钥对id_rsa_user & id_rsa_user.pub并加入私钥部分到SSH身份认证剂和公钥部分GitHub的(“Generating SSH Keys”)。

然后,我创建的文件~/.ssh/config与此内容:

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

最后我改变了项目的远程URL从[email protected]:user/project.git[email protected]:user/project.git(S中的意见this如何使用)。

现在,它的工作对我的VirtualBox虚拟机(Debian的)和TortoiseGit。但是MSysGit抛出一个错误:

(试图推动[email protected]:用户/ project.git)

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

(试图克隆[email protected]:用户/ project.git )

***@**** /path/to/to/project (master) 
$ git clone [email protected]:user/project.git . 
Cloning into '.'... 
fatal: The remote end hung up unexpectedly 

(试图克隆[email protected]:用户/ project.git):

***@**** /path/to/to/project (master) 
$ git clone [email protected]:user/project.git . 
Cloning into '.'... 

enter image description here

fatal: The remote end hung up unexpectedly 

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

THX

编辑:

附加信息 - ssh -v [email protected]输出:

***@**** ~/Desktop/test 
$ ssh -v [email protected] 
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 
+0

什么是灰-v [email protected]的输出? – Gavin 2013-03-08 00:08:42

+0

灰?它是什么? '找不到命令'。但是'$ ssh -T git @ github.com-user'的输出是'Hi user!您已成功验证,但GitHub上不提供外壳access.' – automatix 2013-03-08 00:13:42

+0

对不起,我的意思是SSH ......都怪我的iPad自动更正: - $ ...你做了什么,我想反正所以我现在难倒了,至少要等到我可以在我的电脑前玩耍。 – Gavin 2013-03-08 00:17:48

回答

0

检查你的环境变量GIT_SSH。如果已设置,则取消设置以停止为SSH客户端使用PuTTY。你正在尝试使用openssh config选项,所以你想使用msysgit附带的openssh。

+0

太棒了!非常感谢你! – automatix 2013-03-08 01:26:06