簡體   English   中英

Windows 7上的Git不會通過ssh進行連接,除非已經向服務器打開了另一個ssh連接

[英]Git on Windows 7 does not connect via ssh unless another ssh connection is already open to the server

我在Windows 7上的git確實存在這個怪異的問題。我已經安裝了msysgit,生成了ssh密鑰,並將id_rsa.pub添加到了我的Ubuntu機器上的authorized_keys中。 如果我打開git bash shell並嘗試ssh進入服務器,則會提示輸入密碼。 但是我希望它使用密鑰,而不提示輸入密碼。 現在,如果我首先打開與Ubuntu計算機的ssh連接(通過膩子)並登錄,然后返回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:

通過膩子打開與服務器的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/

我試圖通過ssh進入服務器而不是與git相關時遇到了類似的問題。 實際的問題是服務器上的主目錄已加密。 因此,除非用戶已經登錄,否則不會掛載帶有authorized_keys文件的加密目錄,因此sshd無法訪問該目錄。 如果用戶已經打開了會話,則目錄將被掛載,並且ssh的行為符合預期。

這是針對這種情況的Ubuntu官方幫助: https : //help.ubuntu.com/community/SSH/OpenSSH/Keys#Troubleshooting

這是我使用的解決方案: https : //bugs.launchpad.net/ubuntu/+source/openssh/+bug/362427/comments/12

我從這個線程獲得了這兩個信息: https : //superuser.com/questions/61057/ssh-with-authorized-keys-to-an-ubuntu-system-with-encrypted-homedir

我的直接懷疑是,它正在尋找身份驗證代理,但找不到一個,然后由於某種原因而無法運行ssh-askpass來解鎖您的私鑰。 但是,如果您啟動Putty,它將啟動代理並正確設置它,然后命令行ssh可以使用它來獲取您的私鑰。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM