git 에서 특이한 현상이 있다.


github A 프로젝트를 clone 후,  파일 수정/add/commit/push 한다. 그리고 push를 시도한다.

그러나, github B 프로젝트로 push하는 황당한(?)일이 벌어진다.


ERROR: Permission to ProjectA denied to ProjectB

fatal: The remote end hung up unexpectedly




SSH 디버그로 설정해도 특이한 현상이다. 

$ git clone git@github.xxxx.com:projectA.git Initialized empty Git repository in .... remote: Counting objects: 3194, done. remote: Total 3194 (delta 0), reused 0 (delta 0), pack-reused 3194 Receiving objects: 100% (3194/3194), 9.45 MiB, done. Resolving deltas: 100% (1415/1415), done. $ cd projectA $ vi test $ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: test # no changes added to commit (use "git add" and/or "git commit -a") $ git add . $ git commit -m '11' [master 6d243f2] 11 1 files changed, 1 insertions(+), 0 deletions(-) $ git push debug1: Connecting to github.xxxx.com [1.1.1.1] port 22. debug1: Connection established. debug1: identity file /home/www/.ssh/identity type -1 debug1: identity file /home/www/.ssh/identity-cert type -1 debug1: identity file /home/www/.ssh/id_rsa type -1 debug1: identity file /home/www/.ssh/id_rsa-cert type -1 debug1: identity file /home/www/.ssh/id_dsa type -1 debug1: identity file /home/www/.ssh/id_dsa-cert type -1 debug1: Remote protocol version 2.0, remote software version libssh-0.6.0 debug1: no match: libssh-0.6.0 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-sha1 none debug1: kex: client->server aes128-ctr hmac-sha1 none debug1: sending SSH2_MSG_KEXDH_INIT debug1: expecting SSH2_MSG_KEXDH_REPLY debug1: Host 'github.xxx.com' is known and matches the RSA host key. debug1: Found key in /home/www/.ssh/known_hosts:8 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/www/.ssh/identity debug1: Trying private key: /home/www/.ssh/id_rsa debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = ko_KR.UTF-8 debug1: Sending command: git-receive-pack 'projectA.git' debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 ERROR: Permission to ProjectA denied to ProjectB. debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK Transferred: sent 2208, received 1680 bytes, in 0.1 seconds Bytes per second: sent 38768.0, received 29497.4 debug1: Exit status 1 fatal: The remote end hung up unexpectedly



git config --list 또는 cat .git/config 에서도 projectA.git로 제대로 나온다!!!


문제 해결은 ssh key를 삭제하고 다시 ssh gen을 하고 ssh key를 다시 등록하니 정상적으로 작동했다. 만약 주의 깊게 보지 않고 -f(force push)매개변수를 주었다면 민폐가 되었을 것이다.


아마도 '잘못된 SSH 키가 꼬이면, git push할 때 다른 프로젝트로 결합되어 엉뚱한 작업을 진행할 수 있다'라고 가정할 수 있는 환경을 공유한다.


따라서 git push -f는 정말 신중하게 써야 한다.!! 잘못하면 엉뚱한 github 프로젝트를 엉뚱하게 변경할 가능성이 존재한다.




참고

https://help.github.com/enterprise/2.4/user/articles/error-permission-to-user-repo-denied-to-user-other-repo/



Posted by '김용환'
,