Windows

git push error: client_loop: send disconnect: Connection reset by peer

채윤아빠 2021. 5. 11. 20:56
728x90
반응형

문제점 및 증상

GitLab에 저장소를 두고, 소스 수정 후 "git push" 하던 중에 다음과 같은 오류가 발생하였습니다.

D:\Dev\my_project>git push
Enumerating objects: 59, done.
Counting objects: 100% (49/49), done.
Delta compression using up to 8 threads
Compressing objects: 100% (29/29), done.
Writing objects: 100% (29/29), 3.38 KiB | 691.00 KiB/s, done.
Total 29 (delta 19), reused 0 (delta 0), pack-reused 0
client_loop: send disconnect: Connection reset by peer
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly

"fatal: the remote end hung up unexpectedly" 오류 문구의 내용으로 봤을 때, GitLab 서버 내부에서 알 수 없는 오류로 중단 (hang up) 되어 버리는 현상 같았습니다.

원인 분석

ssh 명령으로 아래와 같이 GitLab 서버의 ssh 접속을 확인해 보았으나, 이상이 없었습니다.

D:\Dev\my_project>ssh git@my.repogitory -v
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\admin/.ssh/config
debug1: C:\\Users\\admin/.ssh/config line 1: Applying options for my.repogitory
debug1: Connecting to my.repogitory [123.123.123.123] port 22.
debug1: Connection established.

...

debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH* compat 0x04000000
debug1: Authenticating to my.repogitory:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ZIBP0LbUb8cK5l2+eqLYFSBhf6IMX7npxMwq/6uWsoc
debug1: Host '[my.repogitory]:22' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\admin/.ssh/known_hosts:3
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:t2M9CXkLWaEfICrSlVbBoqkkDCg6LDT/6G5Q4g/qeOM C:\\Users\\admin/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 407
debug1: Authentication succeeded (publickey).
Authenticated to my.repogitory ([123.123.123.123]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: console supports the ansi parsing
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
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.
PTY allocation request failed on channel 0
Welcome to GitLab, @hbesthee!
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to my.repogitory closed.
Transferred: sent 2664, received 3020 bytes, in 0.1 seconds
Bytes per second: sent 30336.5, received 34390.5
debug1: Exit status 0

다른 브랜치에서 수정한 소스들은 정상적으로 "push"가 가능했는데, 특정 브랜치의 수정된 소스를 "push"할 경우에만 위와 같은 오류가 발생하였습니다.

해결 방안

다른 브랜치는 문제가 없는데, 특정 브랜치에서만 발생하여, ssh 터널링을 하지 않고 https로 "push"하였더니, 정상적으로 "push"가 되었습니다.

"git remote set-url" 명령을 이용하여, 저장소 접속 방식을 ssh 터널링 주소에서 https를 이용하는 방식으로 변경합니다.

D:\Dev\my_project>git remote set-url origin https://hbesthee@my.repogitory/python/my_project.git

D:\Dev\my_project>git remote -v
origin  https://hbesthee@my.repogitory/python/my_project.git (fetch)
origin  https://hbesthee@my.repogitory/python/my_project.git (push)

D:\Dev\my_project>git push
Enumerating objects: 95, done.
Counting objects: 100% (79/79), done.
Delta compression using up to 8 threads
Compressing objects: 100% (29/29), done.
Writing objects: 100% (51/51), 7.58 KiB | 2.53 MiB/s, done.
Total 51 (delta 33), reused 38 (delta 22), pack-reused 0
remote:
remote: To create a merge request for 15487, visit:
remote:   http://my.repogitory/python/my_project/-/merge_requests/new?merge_request%5Bsource_branch%5D=15487
remote:
To https://my.repogitory/python/my_project.git
   fe165e1..fd2c1cf  15487 -> 15487

D:\Dev\my_project>git remote set-url origin ssh://git@my.repogitory/python/my_project.git

D:\Dev\my_project>git remote -v
origin  ssh://git@my.repogitory/python/my_project.git (fetch)
origin  ssh://git@my.repogitory/python/my_project.git (push)

"push"가 성공 후, 저장소 접속 방식을 원래대로 ssh 터널링 주소로 변경하였더니, git도 다시 정상적으로 연계되고 다른 브랜치에서도 pull/push 모두 문제가 없었습니다.