首页 文章

除非已经向服务器打开了另一个ssh连接,否则Windows 7上的Git不会通过ssh连接

提问于
浏览
0

我在Windows 7上使用git时遇到了这个非常奇怪的问题 . 我已经安装了msysgit,生成了ssh密钥,并将id_rsa.pub添加到了我的Ubuntu机器上的authorized_keys . 如果我打开git bash shell并尝试ssh到服务器,它会提示输入密码 . 但是我希望它使用密钥而不是提示输入密码 . 现在,如果我首先打开到Ubuntu机器的ssh连接(通过putty)并登录,然后返回到git bash shell,服务器接受与密钥的连接而没有密码 .

关于可能导致这种联系的奇怪之处的任何想法?

连接到没有与服务器的其他ssh连接的服务器:

$ ssh -v jeremy@192.168.1.248
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/Jeremy/.ssh/config
debug1: Connecting to 192.168.1.248 [192.168.1.248] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Jeremy/.ssh/identity type -1
debug1: identity file /c/Users/Jeremy/.ssh/id_rsa type 1
debug1: identity file /c/Users/Jeremy/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-6ubuntu2
debug1: match: OpenSSH_5.1p1 Debian-6ubuntu2 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 '192.168.1.248' is known and matches the RSA host key.
debug1: Found key in /c/Users/Jeremy/.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,password
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Jeremy/.ssh/identity
debug1: Offering public key: /c/Users/Jeremy/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /c/Users/Jeremy/.ssh/id_dsa
debug1: Next authentication method: password
jeremy@192.168.1.248's password:

通过putty打开与服务器的ssh连接后连接到服务器:

$ ssh -v jeremy@192.168.1.248
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/Jeremy/.ssh/config
debug1: Connecting to 192.168.1.248 [192.168.1.248] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Jeremy/.ssh/identity type -1
debug1: identity file /c/Users/Jeremy/.ssh/id_rsa type 1
debug1: identity file /c/Users/Jeremy/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-6ubuntu2
debug1: match: OpenSSH_5.1p1 Debian-6ubuntu2 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 '192.168.1.248' is known and matches the RSA host key.
debug1: Found key in /c/Users/Jeremy/.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,password
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Jeremy/.ssh/identity
debug1: Offering public key: /c/Users/Jeremy/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Linux curious 2.6.31-23-generic #74-Ubuntu SMP Mon Feb 28 22:20:11 UTC 2011 x86_
64

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

2 回答

相关问题