2013-03-07 79 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