无法通过跳转主机使用 ssh 推送到 gitlab

无法通过跳转主机使用 ssh 推送到 gitlab

我正在尝试将 git repo 从本地计算机推送到防火墙后面的 gitlab 服务器。我可以通过 ssh 连接到防火墙后面的计算机,因此我已进行配置,~/.ssh/config以便与 gitlab 的连接通过第二台计算机作为“跳转主机”。

我第一次推送这个本地仓库时,在 gitlab 的 Web UI 上创建了项目,推送成功了。现在,每次我尝试推送时似乎都会成功,但最后却出现了以下错误:

Write failed: Broken pipe
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

我尝试过以下方法~/.ssh/config

host jumphost
hostname <jumphost_ip>
user userA

host gitlab
hostname <gitlab_ip>
user git
#ProxyCommand ssh -v jumphost nc %h %p
proxycommand ssh -v -W %h:%p jumphost
#proxyjump jumphost

host *
#controlmaster auto
#controlpath ~/.ssh/%r@%h:%p
#controlpersist 1m
tcpkeepalive yes
serveraliveinterval 120

我尝试了在网上找到的 3 个“跳转主机”选项。我尝试过从 WSL(Windows 上的 Bash)进行操作,使用 ssh 版本 6.6.1p1 和 git 1.9.1。我还尝试过从 git 的 Windows 安装程序进行操作,使用 ssh 7.3p1 和 git 2.12.2。

添加命令后-v,我得到了很多看起来正常的输出,但最后显示:

...
debug1: Authentication succeeded (publickey).
Authenticated to <jumphost_ip> ([<jumphost_ip>]:22).
debug1: channel_connect_stdio_fwd <gitlab_ip>:22
debug1: channel 0: new [stdio-forward]
debug1: getpeername failed: Bad file descriptor
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: client_input_global_request: rtype [email protected] want_reply 0
Counting objects: 55, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (20/20), 711.75 KiB | 0 bytes/s, done.
Total 20 (delta 10), reused 11 (delta 1)
debug1: channel 0: FORCE input drain
debug1: stdio forwarding: done
Connection to <gitlab_ip> closed by remote host.
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

新版本显示的内容相同,但不是“packet_write_wait:连接到未知端口 65535:管道损坏”,而是“连接被远程主机关闭”。

我尝试打开,controlmaster心想也许连接关闭得太早了,这样它们就会保持打开状态。我在旧版本上一直遇到同样的错误,而新版本甚至不会启动连接。

推送没有显示在服务器上。

有人见过这个问题吗?这似乎不是什么罕见的情况。

编辑使用LogLevel debug3,最后的输出如下所示:

Authenticated to <gitlab_ip> (via proxy).
debug2: fd 3 setting O_NONBLOCK
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug2: callback start
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env SHELL
debug3: Ignored env TERM
debug3: Ignored env USER
debug3: Ignored env NAME
debug3: Ignored env LS_COLORS
debug3: Ignored env HOSTTYPE
debug3: Ignored env PATH
debug3: Ignored env PWD
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env LOGNAME
debug3: Ignored env LESSOPEN
debug3: Ignored env LESSCLOSE
debug3: Ignored env OLDPWD
debug3: Ignored env _
debug3: Ignored env GIT_PREFIX
debug1: Sending command: git-receive-pack '<repo>'
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Counting objects: 55, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (20/20), 711.75 KiB | 0 bytes/s, done.
Total 20 (delta 10), reused 11 (delta 1)
debug2: channel 0: read<=0 rfd 3 len 0
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain -> closed
debug2: channel 0: rcvd adjust 111231
debug2: channel 0: rcvd adjust 98556
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug1: channel 0: FORCE input drain
debug2: channel 0: rcvd close
debug2: channel 0: send eof
debug2: channel 0: input drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug1: stdio forwarding: done
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o0/0 fd -1/6 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to <gitlab_ip> closed by remote host.
Transferred: sent 734404, received 3544 bytes, in 5.6 seconds
Bytes per second: sent 130904.4, received 631.7
debug1: Exit status -1
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

相关内容