本文介绍了使用PuTTY在Windows上的git push失败(致命:远程端意外挂断)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我准备好做我的第一个, ssh winwin @ mylinuxserver 我非常惊讶地收到此错误消息。 有什么想法为什么会发生这种情况,以及如何解决这个问题? 更新I:本指南,我发现PUTTY.EXE不是正确的exe在git中使用。而应该使用 PLINK.EXE 。 该指南还提示应使用名为GIT_SSH的环境变量来让git知道如何做的魔法。所以,我: 〜/ sb / ws> export GIT_SSH = / cygdrive / c / PROGRA〜2 / putty / PLINK.EXE 〜/ sb / ws> git push ssh:// mylinuxserver /〜winwin / gitrepo master:master 不同的错误: fatal:远程结束意外挂起 我认为这个进展方向正确,但我还是不知道如何解决这个问题。任何想法都会非常感激。 UPDATE II:仍在尝试解决这个谜。这一次我怀疑,因为 git push 没有提示用户名+密码在任何地方,身份验证必须在密钥...所以,我仔细检查了 sshd 配置每此howto 。我发现唯一需要更改的是取消注释 / etc / ssh / sshd_config c>并重新启动服务 service sshd restart 。第一次之后, $ GIT_SSH 提示确认服务器的dss密钥指纹,并确认将密钥存储在缓存中,但...问题仍然存在: fatal:远程端意外挂起 其他想法? (PuTTY的注册表现在包含同一服务器的两个键: rsa2 @ 22:mylinuxserver 和 dss @ 22:mylinuxserver 。嗯...我不知道这是什么意思) 更多诊断信息:键入 $ GIT_SSH -v 会产生: 〜/ sb / ws> $ GIT_SSH -v 查找主机mylinuxserver连接到192.168.1.2端口22 服务器版本:SSH-2.0-OpenSSH_4.2 我们声明版本:SSH-2.0 -PuTTY_Release_0.60 使用SSH协议版本2 进行Diffie-Hellman组交换使用散列SHA-1进行Diffie-Hellman密钥交换主机密钥指纹为: ssh-dss 1024 c8:77:42:4f:76:29:56:4c:ea:b0:11:6a:a6:3c:6a:f7 初始化AES-256 SDCTR客户端 - 服务器加密初始化HMAC-SHA1客户机 - >服务器MAC算法初始化AES-256 SDCTR服务器 - >客户机加密初始化HMAC-SHA1服务器 - >客户机MAC算法登录为:winwin winwin @ mylinuxserver的密码:发送密码访问授予会话的已打开通道分配的pty(速度38400bps,速度38400bps)启动shell /命令上次登录:Wed Jul 13 21:41:12从winmachine 到达目前为止,我的情况的最佳指南: Git,SSH,PuTTY 。 见解: $ GIT_SSH 必须运行一次 PAGEANT.EXE必须在后台运行(并通过系统托盘图标将私钥添加到其中)! ) 必须使用PUTTYGEN.EXE来生成公钥/私钥对 dss不是必须的,rsa就足够了。 更多? (除非 $ GIT_SSH -2 -C -i C:\\Users\\winwin\\\\\\\\\SSH\\private.ppk 成功无密码提示,没有点甚至尝试 git push ...) 复制&将公钥从PuTTY密钥生成器粘贴到 mylinuxserver 中的 /home/winwin/.ssh/authorized_keys 响应上述洞察#5中的命令: 服务器拒绝了我们的密钥 这是一个好的迹象... :)我想我正在解决这个谜。 UPDATE III:在 / etc中将 StrictModes 更改为否 / ssh / sshd_config 在sshd服务器上,我成功与 $ GIT_SSH -2 -C -i C:\\Users\\winwin\\\ \\SSH\\private.ppk 。它仍然提示输入用户名,但是不提示输入密码。 git push ssh:// mylinuxserver /〜winwin / gitrepo master:master 继续失败,并显示相同的错误消息: fatal:远程结束意外挂起 这是疯了。 UPDATE IV: PLUS的 -l用户名参数是关键。我成功地通过创建一个单行shell脚本 /cygdrive/c/PROGRA~2/putty/PLINK.EXE,使 git push -l winwin $ * 并将整个脚本的路径导出到 $ GIT_SSH ,但远程端仍然意外挂起。 这是我在客户端(Windows / PuTTY)端得到的: 〜/ sb / ws> git push ssh:// mylinuxserver /〜winwin / gitrepo master:master 环境: USER = winwin LOGNAME = winwin HOME = / home / winwin PATH = / usr / local / bin:/ bin:/ usr / bin MAIL = / var / mail / winwin SHELL = / bin / bash SSH_CLIENT = 192.168.1.8 50951 22 SSH_CONNECTION = 192.168.1.8 50951 192.168.14.2 22 bash:mylinuxserver:command not found fatal:远程结束意外挂起 这是我在服务器端(Linux / sshd)端得到的: debug1:sshd version OpenSSH_4.2p1 debug1:read PEM private key done:type RSA debug1:private host key:#0 type 1 RSA debug1:read PEM private key done:type DSA debug1:private host key:#1 type 2 DSA debug1:rexec_argv [0] ='/ usr / sbin / sshd' debug1:rexec_argv [1] =' - d' debug1:绑定到端口22 on ::。 服务器监听:: port 22. debug1:绑定到0.0.0.0上的端口22。 绑定到端口22(0.0.0.0)失败:地址已在使用中。 debug1:在调试模式下运行时服务器不会分叉。 debug1:rexec start in 4 out 4 newsock 4 pipe -1 sock 7 debug1:inetd sockets after dupping:3,3 从192.168.1.8端口连接50951 debug1:客户端协议版本2.0;客户端软件版本PuTTY_Release_0.60 debug1:无匹配:PuTTY_Release_0.60 debug1:为协议2.0启用兼容性模式 debug1:本地版本字符串SSH-2.0-OpenSSH_4.2 debug1:permanent_set_uid:74/74 debug1:list_hostkey_types:ssh-rsa,ssh-dss debug1:SSH2_MSG_KEXINIT sent debug1:SSH2_MSG_KEXINIT received debug1:kex:client->服务器aes256-ctr hmac-sha1无 debug1:kex:server->客户端aes256-ctr hmac-sha1无 debug1:SSH2_MSG_KEX_DH_GEX_REQUEST_OLD接收 debug1:SSH2_MSG_KEX_DH_GEX_GROUP已发送 debug1:期望SSH2_MSG_KEX_DH_GEX_INIT debug1:SSH2_MSG_KEX_DH_GEX_REPLY发送 debug1:SSH2_MSG_NEWKEYS发送 debug1:预期SSH2_MSG_NEWKEYS debug1:SSH2_MSG_NEWKEYS收到 debug1:KEX完成 debug1:userauth-request用户winwin服务ssh连接方法无 debug1:尝试0失败0 debug1:PAM:初始化winwin debug1:PAM:将PAM_RHOST设置为win7client debug1:PAM:将PAM_TTY设置为ssh winwin从192.168.1.8端口50951失败ssh2 debug1:userauth-请求用户winwin服务ssh连接方法publickey debug1:attempt 1 failures 1 debug1:测试pkalg / pkblob是否可以接受 debug1:temporarily_use_uid:513/513(e = 0/0) debug1:尝试公钥文件/ home / winwin / .ssh / authorized_keys debug1:匹配的密钥找到:file /home/winwin/.ssh/authorized_keys,第1行找到匹配的RSA密钥:bd:a6:4a:6a:04: 43:8d:60:d9:bf:66:de:51:13:83:66 debug1:restore_uid:0/0 从192.168.1.8端口50951推迟winwin的publickey ssh2 debug1:userauth-request用户winwin服务ssh连接方法publickey debug1:尝试2个失败1 debug1:temporarily_use_uid:513/513(e = 0/0) debug1:公共密钥文件/home/winwin/.ssh/authorized_keys debug1:匹配的密钥找到:file /home/winwin/.ssh/authorized_keys,第1行找到匹配的RSA密钥:bd:a6:4a: 6a:04:43:8d:60:d9:bf:66:de:51:13:83:66 debug1:restore_uid:0/0 debug1:ssh_rsa_verify:signature correct debug1:do_pam_account:called 从192.168.1.8端口50951接受的winwin的publickey ssh2 debug1:monitor_child_preauth:winwin已通过特权进程认证从192.168.1.8端口50951接受publickey for winwin端口50951 ssh2 debug1:PAM:重新初始化凭据 debug1:permanent_set_uid:513/513 debug1:输入SSH2的交互式会话。 debug1:server_init_dispatch_20 debug1:server_input_channel_open:ctype session rchan 256 win 16384 max 16384 debug1:input_session_request debug1:channel 0:new [server-session] debug1 :session_new:init debug1:session_new:session 0 debug1:session_open:channel 0 debug1:session_open:session 0:与通道0链接 debug1:server_input_channel_open:confirm session debug1:server_input_channel_req:channel 0 request exec reply 1 debug1:session_by_channel:session 0 channel 0 debug1:session_input_channel_req:session 0 req exec debug1:Received SIGCHLD。 debug1:session_by_pid:pid 3441 debug1:session_exit_message:session 0 channel 0 pid 3441 debug1:session_exit_message:release channel 0 debug1:session_close:session 0 pid 3441 debug1:channel 0:free:server-session,nchannels 1 关闭的连接192.168.1.8 debug1:do_cleanup debug1:PAM:cleanup 关闭连接to 192.168.1.8 debug1:PAM:cleanup p> bash:mylinuxserver:command not found 是什么意思? git push 试图运行? 哪个命令? 在客户端或SSH服务器上? 解决方案 c> git 使用 PuTTY 。进一步的时间投资在我身边似乎没有理由投资回报率,所以我放弃。 Excited about being ready to do my first git push ever, I created an alias for PuTTY in my cygwin environment:alias ssh="/cygdrive/c/PROGRA~2/putty/PUTTY.EXE"Then invoked (inside my working directory, of course), just as explained in page 47 in the git community book:git push ssh://mylinuxserver/~winwin/gitrepo master:masterMy excitement didn't last very long, as it immediately failed with a fatal error:error: cannot run ssh: No such file or directoryfatal: unable to forkConsidering that I am able to run successfully, from the same exact command line and shell instance, ssh winwin@mylinuxserver I am very surprised to receive this error message.Any idea why this is happening and how to fix this?UPDATE I: Thanks to this guide, I discovered that PUTTY.EXE is not the correct exe to use in git. Instead, one should be using PLINK.EXE.That guide also hints that an environment variable, named GIT_SSH, should be used to let git know how to do the magic. So, I:~/sb/ws> export GIT_SSH=/cygdrive/c/PROGRA~2/putty/PLINK.EXE~/sb/ws> git push ssh://mylinuxserver/~winwin/gitrepo master:masterAnd now I am receiving a different error:fatal: The remote end hung up unexpectedlyI consider this progress in the right direction but I still don't know how to solve the problem. Any idea would be very appreciated.UPDATE II: Still trying to troubleshoot this mystery. This time I suspected that since git push doesn't prompt for username+password anywhere, authentication must lie within the keys... So, I double-checked sshd configuration per this howto. The only thing I found as needing change was uncommenting the line HostKey /etc/ssh/ssh_host_dsa_key in /etc/ssh/sshd_config and restarting the service service sshd restart. The first time after that, $GIT_SSH did prompt for confirming the server's dss key fingerprint and I confirmed storing the key in cache, but... The problem still persists:fatal: The remote end hung up unexpectedlyAdditional ideas?(PuTTY's registry now contain two keys for the same server: rsa2@22:mylinuxserver and dss@22:mylinuxserver. Hmmm... I am not sure what this means)More diagnostic info: Typing $GIT_SSH -v yields:~/sb/ws> $GIT_SSH -vLooking up host "mylinuxserver"Connecting to 192.168.1.2 port 22Server version: SSH-2.0-OpenSSH_4.2We claim version: SSH-2.0-PuTTY_Release_0.60Using SSH protocol version 2Doing Diffie-Hellman group exchangeDoing Diffie-Hellman key exchange with hash SHA-1Host key fingerprint is:ssh-dss 1024 c8:77:42:4f:76:29:56:4c:ea:b0:11:6a:a6:3c:6a:f7Initialised AES-256 SDCTR client->server encryptionInitialised HMAC-SHA1 client->server MAC algorithmInitialised AES-256 SDCTR server->client encryptionInitialised HMAC-SHA1 server->client MAC algorithmlogin as: winwinwinwin@mylinuxserver's password:Sent passwordAccess grantedOpened channel for sessionAllocated pty (ospeed 38400bps, ispeed 38400bps)Started a shell/commandLast login: Wed Jul 13 21:41:12 2011 from winmachineCan you spot anything suspicious?Getting there: By far the best guide for my situation: Git, SSH, PuTTY.Insights:$GIT_SSH -agent must be run oncePAGEANT.EXE must be running in the background (and private key added to it via its systray icon!)PUTTYGEN.EXE must be used to generate a public/private keys pairdss not mandatory, rsa is good enough.More? (unless $GIT_SSH -2 -C -i C:\\Users\\winwin\\SSH\\private.ppk succeeds without password prompt, there is no point to even try git push...)After copying & pasting the public key from PuTTY Key Generator to /home/winwin/.ssh/authorized_keys in mylinuxserver a new message showed up in response to the command in insight #5 above:Server refused our keyThis is a good sign... :) I think I am on my way to solving the mystery.UPDATE III: After changing StrictModes to no in /etc/ssh/sshd_config on the sshd server, I managed to succeed with $GIT_SSH -2 -C -i C:\\Users\\winwin\\SSH\\private.ppk. It still prompts for the username, though (but doesn't prompt for password).git push ssh://mylinuxserver/~winwin/gitrepo master:master continues to fail however -- with the same error message:fatal: The remote end hung up unexpectedlyThis is insane.UPDATE IV: The -l username parameter to PLINK is key. I managed to make git push login successfully, by creating a 1-line shell script /cygdrive/c/PROGRA~2/putty/PLINK.EXE -l winwin $* and exporting the the entire script's path to $GIT_SSH, but "the remote end still hangs up unexpectedly".This is what I am getting on the client (Windows/PuTTY) side:~/sb/ws> git push ssh://mylinuxserver/~winwin/gitrepo master:masterEnvironment: USER=winwin LOGNAME=winwin HOME=/home/winwin PATH=/usr/local/bin:/bin:/usr/bin MAIL=/var/mail/winwin SHELL=/bin/bash SSH_CLIENT=192.168.1.8 50951 22 SSH_CONNECTION=192.168.1.8 50951 192.168.14.2 22bash: mylinuxserver: command not foundfatal: The remote end hung up unexpectedlyAnd This is what I am getting on the server side (Linux/sshd) side:debug1: sshd version OpenSSH_4.2p1debug1: read PEM private key done: type RSAdebug1: private host key: #0 type 1 RSAdebug1: read PEM private key done: type DSAdebug1: private host key: #1 type 2 DSAdebug1: rexec_argv[0]='/usr/sbin/sshd'debug1: rexec_argv[1]='-d'debug1: Bind to port 22 on ::.Server listening on :: port 22.debug1: Bind to port 22 on 0.0.0.0.Bind to port 22 on 0.0.0.0 failed: Address already in use.debug1: Server will not fork when running in debugging mode.debug1: rexec start in 4 out 4 newsock 4 pipe -1 sock 7debug1: inetd sockets after dupping: 3, 3Connection from 192.168.1.8 port 50951debug1: Client protocol version 2.0; client software version PuTTY_Release_0.60debug1: no match: PuTTY_Release_0.60debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_4.2debug1: permanently_set_uid: 74/74debug1: list_hostkey_types: ssh-rsa,ssh-dssdebug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT receiveddebug1: kex: client->server aes256-ctr hmac-sha1 nonedebug1: kex: server->client aes256-ctr hmac-sha1 nonedebug1: SSH2_MSG_KEX_DH_GEX_REQUEST_OLD receiveddebug1: SSH2_MSG_KEX_DH_GEX_GROUP sentdebug1: expecting SSH2_MSG_KEX_DH_GEX_INITdebug1: SSH2_MSG_KEX_DH_GEX_REPLY sentdebug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: SSH2_MSG_NEWKEYS receiveddebug1: KEX donedebug1: userauth-request for user winwin service ssh-connection method nonedebug1: attempt 0 failures 0debug1: PAM: initializing for "winwin"debug1: PAM: setting PAM_RHOST to "win7client"debug1: PAM: setting PAM_TTY to "ssh"Failed none for winwin from 192.168.1.8 port 50951 ssh2debug1: userauth-request for user winwin service ssh-connection method publickeydebug1: attempt 1 failures 1debug1: test whether pkalg/pkblob are acceptabledebug1: temporarily_use_uid: 513/513 (e=0/0)debug1: trying public key file /home/winwin/.ssh/authorized_keysdebug1: matching key found: file /home/winwin/.ssh/authorized_keys, line 1Found matching RSA key: bd:a6:4a:6a:04:43:8d:60:d9:bf:66:de:51:13:83:66debug1: restore_uid: 0/0Postponed publickey for winwin from 192.168.1.8 port 50951 ssh2debug1: userauth-request for user winwin service ssh-connection method publickeydebug1: attempt 2 failures 1debug1: temporarily_use_uid: 513/513 (e=0/0)debug1: trying public key file /home/winwin/.ssh/authorized_keysdebug1: matching key found: file /home/winwin/.ssh/authorized_keys, line 1Found matching RSA key: bd:a6:4a:6a:04:43:8d:60:d9:bf:66:de:51:13:83:66debug1: restore_uid: 0/0debug1: ssh_rsa_verify: signature correctdebug1: do_pam_account: calledAccepted publickey for winwin from 192.168.1.8 port 50951 ssh2debug1: monitor_child_preauth: winwin has been authenticated by privileged processAccepted publickey for winwin from 192.168.1.8 port 50951 ssh2debug1: PAM: reinitializing credentialsdebug1: permanently_set_uid: 513/513debug1: Entering interactive session for SSH2.debug1: server_init_dispatch_20debug1: server_input_channel_open: ctype session rchan 256 win 16384 max 16384debug1: input_session_requestdebug1: channel 0: new [server-session]debug1: session_new: initdebug1: session_new: session 0debug1: session_open: channel 0debug1: session_open: session 0: link with channel 0debug1: server_input_channel_open: confirm sessiondebug1: server_input_channel_req: channel 0 request exec reply 1debug1: session_by_channel: session 0 channel 0debug1: session_input_channel_req: session 0 req execdebug1: Received SIGCHLD.debug1: session_by_pid: pid 3441debug1: session_exit_message: session 0 channel 0 pid 3441debug1: session_exit_message: release channel 0debug1: session_close: session 0 pid 3441debug1: channel 0: free: server-session, nchannels 1Connection closed by 192.168.1.8debug1: do_cleanupdebug1: PAM: cleanupClosing connection to 192.168.1.8debug1: PAM: cleanupLast clue needed... What does bash: mylinuxserver: command not found mean?What is git push trying to run?Which command?On the client or the SSH server? 解决方案 I never succeeded making git work with PuTTY. Further time investment on my side didn't seem to justify ROI, so I am giving up. 这篇关于使用PuTTY在Windows上的git push失败(致命:远程端意外挂断)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-15 01:40