【问题标题】:How to make MSysGit work with non-default key file names?如何使 MSysGit 使用非默认密钥文件名?
【发布时间】:2013-02-23 09:53:10
【问题描述】:

为了对多个 GitHub 帐户使用多个密钥(在 this how-to 之后),我希望首先让我的本地系统使用命名为默认 id_rsa 以外的密钥文件。

我创建了一个密钥对 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 从 git@github.com:user/project.git 更改为 git@github.com-user:user/project.git(将 cmets 更改为 this how-to)。

现在它正在我的 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

【问题讨论】:

  • ash -v git@github.com-user 的输出是什么?
  • 灰?它是什么? Command not found。但是$ ssh -T git@github.com-user 的输出是Hi user! You've successfully authenticated, but GitHub does not provide shell access.
  • 对不起,我的意思是 ssh ......我责怪 iPad 自动更正 :-$ ......你做了我想做的事,所以我现在很难过,至少直到我可以在我的面前玩耍个人电脑。
  • 啊,好的。我已经编辑了我的问题帖子并将输出添加到底部。

标签: git connection msysgit msys


【解决方案1】:

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

【讨论】:

  • 太棒了!非常感谢!
猜你喜欢
  • 2023-03-08
  • 1970-01-01
  • 2013-02-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-22
  • 1970-01-01
相关资源
最近更新 更多