728x90
반응형
문제점 및 증상
OS 재설치 전, git 을 이용한 clone, push, pull 등은 정상적으로 동작하였으나,
OS를 재설치한 이후에 push하려고 하면 다음과 같이 "fatal: Could not read from remote repository." 오류가 발생하며 push가 실패하는 문제가 발생하였습니다.
> git push
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
원인분석
다음과 같이 ssh 명령으로 직접 GitLab 서버에 접속해 보았더니, 다음과 같이 SSH2_MSG_KEX_ECDH_REPLY 이후에 연결이 끊어지는 현상이 발생하였습니다.
$ ssh git@gitlab.my-server.net -p18022 -v
OpenSSH_8.7p1, OpenSSL 1.1.1k 25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to gitlab.my-server.net [49.247.203.109] port 18022.
debug1: Connection established.
debug1: identity file /c/Users/hanwh/.ssh/id_rsa type 0
debug1: identity file /c/Users/hanwh/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_dsa type -1
debug1: identity file /c/Users/hanwh/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_xmss type -1
debug1: identity file /c/Users/hanwh/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: compat_banner: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to gitlab.my-server.net:18022 as 'git'
debug1: load_hostkeys: fopen /c/Users/hanwh/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
Connection reset by 49.247.203.109 port 18022
해결 방안
아래 관련 참고자료를 바탕으로 이것 저것 시도해 보았습니다.
MTU를 변경하여도, push가 잘 동작하였습니다.
그러나 정상적인 크기를 강제로 조정하는 것이 임시 방편처럼 느껴졌었는데, ssh가 클라이언트로 접속할 때 암호화 방식을 조정하여 손쉽게 해결이 가능하였습니다.
다음과 같이 local에 config 설정 파일을 만들어 줍니다.
$ echo -e "Host gitlab.my-server.net\n\tMACs hmac-sha2-512,hmac-sha2-256" > ~/.ssh/config
$ cat ~/.ssh/config
Host gitlab.my-server.net
hmac-sha2-512,MACs hmac-sha2-256
이후 GitLab 서버에 ssh 접속을 확인해 보면, 정상적으로 접속이 이루어지는 것을 확인할 수 있습니다.
$ ssh git@gitlab.my-server.net -p18022 -v
OpenSSH_8.7p1, OpenSSL 1.1.1k 25 Mar 2021
debug1: Reading configuration data /c/Users/hanwh/.ssh/config
debug1: /c/Users/hanwh/.ssh/config line 1: Applying options for gitlab.my-server.net
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to gitlab.my-server.net [49.247.203.109] port 18022.
debug1: Connection established.
debug1: identity file /c/Users/hanwh/.ssh/id_rsa type 0
debug1: identity file /c/Users/hanwh/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_dsa type -1
debug1: identity file /c/Users/hanwh/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/hanwh/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/hanwh/.ssh/id_xmss type -1
debug1: identity file /c/Users/hanwh/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: compat_banner: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to gitlab.my-server.net:18022 as 'git'
debug1: load_hostkeys: fopen /c/Users/hanwh/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:ukwOXiA+mrPM1Pj4T87pOWLNpl1TYj22N6KsohCjV6s
debug1: load_hostkeys: fopen /c/Users/hanwh/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '[gitlab.my-server.net]:18022' is known and matches the ED25519 host key.
debug1: Found key in /c/Users/hanwh/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_rsa RSA SHA256:INVhzjMdGu10nq6rMog6tAb8lL++7RbMUyLQiZISiRw
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_dsa
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/hanwh/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
...
Welcome to GitLab, @hanwh!
debug1: channel 0: free: client-session, nchannels 1
Connection to gitlab.my-server.net closed.
Transferred: sent 3168, received 2940 bytes, in 0.2 seconds
Bytes per second: sent 13327.4, received 12368.2
debug1: Exit status 0
git push 가 정상적으로 동작하였습니다.
> git push
Enumerating objects: 15, done.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 1.10 KiB | 1.10 MiB/s, done.
Total 8 (delta 6), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for 16162, visit:
remote: http://gitlab.my-server.net/ace/scc/-/merge_requests/new?merge_request%5Bsource_branch%5D=16162
remote:
To ssh://gitlab.my-server.net:18022/ace/scc.git
73c4378..bbff8f7 16162 -> 16162
참고자료
- "Cannot SSH: debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY":https://serverfault.com/questions/210408/
- "Improve your SSH experience: use an ssh config file":https://diego.assencio.com/?index=771ffcf2efe6efe3e934d81cb6b8bbfb
'Linux,Unix,BSD' 카테고리의 다른 글
[shell] 특정 문자열이 포함된 줄 번호 출력하기 (0) | 2021.10.26 |
---|---|
git push error - sha1 file '<stdout>' write error: Broken pipe (0) | 2021.10.05 |
[linux] 시스템 재부팅 및 동작시간 확인하기 (0) | 2021.09.24 |
[git] Linux 터미널에서 암호 저장 설정하기 (0) | 2021.09.12 |
Ubuntu 20.04.2 LTS 에서 랜카드의 속도 확인 방법 (0) | 2021.08.23 |