簡體   English   中英

AWS CodeCommit - 可以克隆/拉取但不能推送(SSH)

[英]AWS CodeCommit - Can clone/pull but can't push (SSH)

我已按照文檔化的步驟創建和克隆CodeCommit存儲庫( 根據AWS文檔 )。

我還驗證了我使用了正確的私鑰和公鑰(根據這個答案 )。

我的ssh配置文件配置正確(見這里 )。

用戶附加了AWSCodeCommitFullAccess策略(包括CodeCommit:GitPush操作)。

我可以成功克隆並拉出存儲庫,但是當我嘗試推送提交時,我收到以下消息:

You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit.
Connection to git-codecommit.ap-southeast-2.amazonaws.com closed by remote host.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我使用的是Ubuntu 16.04和git 2.7.4版

輸出GIT_TRACE_PACKET=true GIT_TRACE=2 GIT_CURL_VERBOSE=1 GIT_SSH_COMMAND="ssh -v" git push

15:14:19.048714 git.c:369               trace: built-in: git 'push'
15:14:19.049478 run-command.c:369       trace: run_command: 'ssh -v' 'awsgit' 'git receive-pack '\''/v1/repos/hsm'\'''
15:14:19.050040 run-command.c:228       trace: exec: '/bin/sh' '-c' 'ssh -v "$@"' 'ssh -v' 'awsgit' 'git receive-pack '\''/v1/repos/hsm'\'''
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/daniel/.ssh/config
debug1: /home/daniel/.ssh/config line 21: Applying options for awsgit
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to git-codecommit.ap-southeast-2.amazonaws.com [103.8.175.151] port 22.
debug1: Connection established.
debug1: identity file /home/daniel/.ssh/keys/awsgit/awsgit type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/daniel/.ssh/keys/awsgit/awsgit-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version AWSCodeCommit     VHVlLCAyNyBKdW4gMjAxNyAwMzoxNDowNSArMDAwMLPfiCbgvY3jqs8ZWuJKQYkz8fFRYb9bCPqRK5nPaegeOk
debug1: no match: AWSCodeCommit VHVlLCAyNyBKdW4gMjAxNyAwMzoxNDowNSArMDAwMLPfiCbgvY3jqs8ZWuJKQYkz8fFRYb9bCPqRK5nPaegeOk5IMVgvTXRVQ1VzQWZCMUc2    aXM1WlFSZS9sOXZCTHY0UE9NUWt0UWJuaVU9
debug1: Authenticating to git-codecommit.ap-southeast-2.amazonaws.com:22 as 'APKAJ...[redacted]'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:nYp+gHas80HY3...[redacted]
debug1: Host 'git-codecommit.ap-southeast-2.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /home/daniel/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/daniel/.ssh/keys/awsgit/awsgit
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to git-codecommit.ap-southeast-2.amazonaws.com ([103.8.175.151]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_NZ.UTF-8
debug1: Sending command: git receive-pack '/v1/repos/hsm'
You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit.
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to git-codecommit.ap-southeast-2.amazonaws.com closed by remote host.
Transferred: sent 2960, received 2040 bytes, in 0.1 seconds
Bytes per second: sent 41330.3, received 28484.4
debug1: Exit status -1
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我究竟做錯了什么? 謝謝你的幫助!

無論出於何種原因,看起來您的git客戶端版本正在發送命令:

git receive-pack'/ v1 / repos / hsm'

我自己跑了一個詳細的推動,我看到:

git-receive-pack'/ v1 / repos / MyRepoName'

請注意,您的客戶端似乎正在發送空格字符而不是連字符。 這告訴我,您使用的版本中可能存在錯誤? 我建議嘗試更新到最新版本的git客戶端。

編輯:也許嘗試強制您的git客戶端使用正確的命令。 使用用於receivepack操作的命令編輯git config:

git config --edit --global

然后,在您的遙控器(可能是原點?)下,添加:

[remote "origin"]
    receivepack = 'git-receive-pack'

從我可以收集到的,這個問題與你的ssh設置或git本身無關。

這可能是一個遠程提取,但你可以檢查你是否有任何shell初始化腳本,如.bashrc,.profile,.bash_login等。這可能是失敗的原因,暫時嘗試禁用/注釋掉文件。

否則,您是否可以通過運行提供更多調試信息

GIT_TRACE_PACKET = true GIT_TRACE = 2 GIT_CURL_VERBOSE = 1 git push ssh -v

不確定ssh是否是問題,但我通常只做ssh-copy-id <user>@<ip>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM