在Windows上使用PuTTY进行git推送失败(致命:远程端意外挂断)

2023-11-26

为准备好做我的第一次而感到兴奋git push曾经,我为PuTTY在我的 cygwin 环境中:

alias ssh="/cygdrive/c/PROGRA~2/putty/PUTTY.EXE"

然后调用(当然是在我的工作目录中),正如第 47 页中所述git 社区书籍:

git push ssh://mylinuxserver/~winwin/gitrepo master:master

我的兴奋并没有持续多久,因为它立即失败并出现致命错误:

error: cannot run ssh: No such file or directory
fatal: unable to fork

考虑到我能够成功运行,来自相同的命令行和 shell 实例, ssh winwin@mylinuxserver收到此错误消息我感到非常惊讶。

知道为什么会发生这种情况以及如何解决这个问题吗?

更新一:谢谢本指南,我发现 PUTTY.EXE 不是在 git 中使用的正确 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: The remote end hung up unexpectedly

我认为这个进展是正确的,但我仍然不知道如何解决问题。任何想法将不胜感激。

更新二:仍在努力解开这个谜团。这次我怀疑自从git push不会在任何地方提示输入用户名+密码,身份验证必须位于密钥内......所以,我仔细检查了sshd配置每这个指南。我发现唯一需要更改的是取消注释该行HostKey /etc/ssh/ssh_host_dsa_key in /etc/ssh/sshd_config并重新启动服务service sshd restart。在那之后的第一次,$GIT_SSH确实提示确认服务器的 dss 密钥指纹,并且我确认将密钥存储在缓存中,但是......问题仍然存在:

fatal: The remote end hung up unexpectedly

其他想法?

(PuTTY 的注册表现在包含同一服务器的两个密钥:rsa2@22:mylinuxserver and dss@22:mylinuxserver。嗯......我不确定这意味着什么)

更多诊断信息: Typing $GIT_SSH -v yields:

~/sb/ws> $GIT_SSH -v
Looking up host "mylinuxserver"
Connecting to 192.168.1.2 port 22
Server version: SSH-2.0-OpenSSH_4.2
We claim version: SSH-2.0-PuTTY_Release_0.60
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-dss 1024 c8:77:42:4f:76:29:56:4c:ea:b0:11:6a:a6:3c:6a:f7
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
login as: winwin
winwin@mylinuxserver's password:
Sent password
Access granted
Opened channel for session
Allocated pty (ospeed 38400bps, ispeed 38400bps)
Started a shell/command
Last login: Wed Jul 13 21:41:12 2011 from winmachine

你能发现任何可疑的地方吗?

到达那里:到目前为止,适合我的情况的最佳指南:git、SSH、腻子.

见解:

  1. $GIT_SSH -agent必须运行一次
  2. PAGEANT.EXE 必须在后台运行(并且通过其私钥添加到它)系统托盘图标!)
  3. 必须使用 PUTTYGEN.EXE 生成公钥/私钥对
  4. dss不是强制性的,rsa就足够了。
  5. More? (除非$GIT_SSH -2 -C -i C:\\Users\\winwin\\SSH\\private.ppk在没有密码提示的情况下成功,没有必要尝试git push...)

将公钥从 PuTTY 密钥生成器复制并粘贴到/home/winwin/.ssh/authorized_keys in mylinuxserver一条新消息出现以响应上面见解 #5 中的命令:

Server refused our key

这是一个好兆头...:)我想我正在解开这个谜团。

更新三:改变后StrictModes to no in /etc/ssh/sshd_config在 sshd 服务器上,我成功了$GIT_SSH -2 -C -i C:\\Users\\winwin\\SSH\\private.ppk。但它仍然提示输入用户名(但不提示输入密码)。

git push ssh://mylinuxserver/~winwin/gitrepo master:master但是仍然失败 - 并显示相同的错误消息:

fatal: The remote end hung up unexpectedly

疯了吧。

更新四: The -l usernamePLINK 的参数是关键。我设法使git push通过创建1行shell脚本登录成功/cygdrive/c/PROGRA~2/putty/PLINK.EXE -l winwin $*并将整个脚本的路径导出到$GIT_SSH,但“远端仍然意外挂断”。

这是我在客户端 (Windows/PuTTY) 端得到的信息:

~/sb/ws> git push ssh://mylinuxserver/~winwin/gitrepo master:master
Environment:
  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: The remote end hung up unexpectedly

这就是我在服务器端(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: 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 7
debug1: inetd sockets after dupping: 3, 3
Connection from 192.168.1.8 port 50951
debug1: Client protocol version 2.0; client software version PuTTY_Release_0.60
debug1: no match: PuTTY_Release_0.60
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.2
debug1: permanently_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->server aes256-ctr hmac-sha1 none
debug1: kex: server->client aes256-ctr hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST_OLD received
debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT
debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: KEX done

debug1: userauth-request for user winwin service ssh-connection method none
debug1: attempt 0 failures 0
debug1: 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 ssh2
debug1: userauth-request for user winwin service ssh-connection method publickey
debug1: attempt 1 failures 1
debug1: test whether pkalg/pkblob are acceptable
debug1: temporarily_use_uid: 513/513 (e=0/0)
debug1: trying public key file /home/winwin/.ssh/authorized_keys
debug1: matching key found: file /home/winwin/.ssh/authorized_keys, line 1
Found matching RSA key: bd:a6:4a:6a:04:43:8d:60:d9:bf:66:de:51:13:83:66
debug1: restore_uid: 0/0
Postponed publickey for winwin from 192.168.1.8 port 50951 ssh2
debug1: userauth-request for user winwin service ssh-connection method publickey
debug1: attempt 2 failures 1
debug1: temporarily_use_uid: 513/513 (e=0/0)
debug1: trying public key file /home/winwin/.ssh/authorized_keys
debug1: matching key found: file /home/winwin/.ssh/authorized_keys, line 1
Found matching RSA key: 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
Accepted publickey for winwin from 192.168.1.8 port 50951 ssh2
debug1: monitor_child_preauth: winwin has been authenticated by privileged process
Accepted publickey for winwin from 192.168.1.8 port 50951 ssh2
debug1: PAM: reinitializing credentials
debug1: permanently_set_uid: 513/513
debug1: Entering interactive session for 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: link with channel 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

Connection closed by 192.168.1.8
debug1: do_cleanup
debug1: PAM: cleanup
Closing connection to 192.168.1.8
debug1: PAM: cleanup

需要最后一条线索...

  1. 什么是bash: mylinuxserver: command not found mean?
  2. What is git push试图逃跑?
  3. 哪个命令?
  4. 在客户端还是 SSH 服务器上?

使用plink?您可能需要重新创建为 putty 创建的密钥。

http://www.xinotes.org/notes/note/156/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在Windows上使用PuTTY进行git推送失败(致命:远程端意外挂断) 的相关文章

  • 我可以从命令行向 github 添加问题吗?

    我是 git 新手 我希望能够通过 github 绘制我的项目的计划和进度 问题是 这需要在 github com 上使用浏览器进行大量点击 并且我希望能够通过使用命令行程序来自动执行该任务 github 有命令行界面吗 有一个ghi ge
  • 在 Windows 上将 Mercurial (hg) 存储库转换为 Git (7)

    我现在真的很沮丧 我有一个现有的 hg 存储库 其中有几个月的编码历史 我想将其放入私有 Github 存储库中 以便我可以从那里对其进行处理 不幸的是我使用的是 Windows 我似乎找不到any转换我实际上可以正常工作的存储库的方法 实
  • 在 git 提交消息中使用任何 utf-8 字符是否安全?

    我发现使用 UTF8 字符 例如 很有用 请参阅here http www utf8icons com subsets dingbats 在提交消息中 重构 NewService 添加了更好的服务 OldServiceA 据我所见 它see
  • 如何使用 libgit2 创建空提交?

    我一直在寻找libgit2 C API 参考 https libgit2 org libgit2 但我不知道如何模仿git commit allow empty libgit2 是否有内置方法来创建空提交 如果没有 git 如何在底层创建一
  • 如何获取第一次提交的 Git diff?

    我创建了一个存储库 在其中创建了一个文件 在文件中放入了一些内容 然后提交了该文件 现在 我想查看该提交的差异 理想情况下应该显示添加的文件以及添加到其中的行 然而 git diff HEAD HEAD回报fatal ambiguous a
  • 有关多个远程存储库的 Git 状态

    我有一个脚本 如果我忘记在 40 多个存储库中提交或推送一些代码 它会通过电子邮件向我发送提醒 在我的两个项目中 我遵循了这些帖子中的答案 其中我设置了 git push 来推送到多个存储库 从多个远程位置拉 推 https stackov
  • 如何让 git 和 copSSH 在正确的目录中查找密钥?

    我刚刚安装了 Windows 版 copSSH 当我启动它时 我得到一个目录C copSSH home Nick ssh其中有我的酒吧和私钥 当我通过 Cygwin bash 窗口访问此目录时 使用 ssh 用户 主机 我很高兴地登录了 但
  • web2py git 集成 - localhost 和 pythonanywhere

    我完全不知道如何将 Github 集成到 web2py 中 我在 USB 上安装了 web2py任何地方的Python http www pythonanywhere com web2py概述文档chapter3http web2py co
  • Python 无法在 git bash 命令行中工作

    Python 不会在 git bash Windows 中运行 当我在命令行中输入 python 时 它会将我带到一个空行 而不会像在 Powershell 中一样显示它已输入 python 2 7 10 它没有给我错误消息 但 pytho
  • 为什么在 Eclipse 中对 Egit 管理的项目禁用合并工具?

    根据Egit 用户指南 http wiki eclipse org EGit User Guide Using Merge Tool 要使用合并工具 应右键单击存在合并冲突的资源 然后选择Team gt 合并工具 但是 当我执行此操作时 合
  • EGit(Eclipse git 插件)可以使用 SSH 密钥代替用户名和密码吗?

    我需要提交的 git 中央存储库是使用 SSH 密钥配置的 我的用户名是jmglov 但是当我执行 git 操作时 例如git clone 我使用这个配置 jmglov kitiara cat git config remote origi
  • git Branch -d :致命 - 无法查找 HEAD 的提交对象

    假设我在一个裸存储库 远程 中 如果我尝试使用以下命令删除分支git branch d
  • Eclipse 与外部 src 和 Web 内容文件夹链接或映射

    首先这不是问题但是我遇到的问题的解决方案浪费了4 5个小时来找到解决方案 请让我知道是否有更好的替代方法来使用 eclipse 项目管理外部 src 文件夹 我正在使用版本控制系统 GIT 来管理我的项目 还使用外部 Git 客户端 Sou
  • gitlab 上的权限被拒绝(公钥)

    我的问题是我无法从 GitLab 推送或获取 不过 我可以克隆 通过 HTTP 或通过 SSH 当我尝试推送时出现此错误 权限被拒绝 公钥 致命 无法从远程存储库读取 从我看过的所有线程中 这是我所做的 在我的计算机上设置 SSH 密钥并将
  • 在 Web 应用程序中显示最新的提交值?

    我有一些 Rails 应用程序 我使用 Git 作为版本控制系统 我使用 GitHub 或 Beanstalk 作为存储库主机 从理论上讲 我想要做的事情非常简单 以某种方式在 Web 应用程序的页脚中显示最新的提交 ID 号 哈希值 这样
  • SSH,运行进程然后忽略输出

    我有一个命令可以使用 SSH 并在 SSH 后运行脚本 该脚本运行一个二进制文件 脚本完成后 我可以输入任意键 本地终端将恢复到正常状态 但是 由于该进程仍在我通过 SSH 连接的计算机中运行 因此任何时候它都会登录到stdout我在本地终
  • 按时间顺序将多个文件夹提交到 git 中

    我有数百个网站备份 每个文件夹一个 我想将它们放入 git 存储库中 每个备份作为一个版本 这些变化主要涉及图像文件和每天 2 个数据库备份 大小约为 25 GB 并且不断增加 有没有办法告诉 git 获取其中一个文件夹并将其提交到存储库中
  • 未能将一些参考推送至 [email protected]

    当我尝试推送到 Heroku 存储库时收到此错误 我已经设置了autocrlf false在gitconfig中 但这个问题仍然存在 我也尝试过这个解决方案here https stackoverflow com questions 566
  • 我在哪里? *(无分支)

    我已经熟悉了创建 合并和删除分支 我想知道我在哪里 这样我就不会将工作提交到错误的分支 我用git branch a看看我有哪些分支 我认为星号 显示我当前所在的分支 当我得到以下信息时 这意味着什么 no branch master or
  • 无法使用 git 推送或获取 [重复]

    这个问题在这里已经有答案了 我可以拉 但无法使用 git 版本 1 9 5 推送或获取 它突然开始给我以下错误 关于如何修复它有什么想法吗 git fetch fatal unable to access https email prote

随机推荐