Git AWS CodeCommit-可以克隆/拉取,但可以';t推送(SSH)
我按照文档中的步骤创建和克隆了CodeCommit存储库(根据) 我还验证了我正在使用正确的私钥和公钥(根据) 我的ssh配置文件配置正确(请参阅) 用户附加了AWSCodeCommitFullAccess策略(包括CodeCommit:GitPush操作) 我可以成功克隆并拉取存储库,但是当我尝试推送提交时,会收到以下消息:Git AWS CodeCommit-可以克隆/拉取,但可以';t推送(SSH),git,amazon-web-services,ssh,aws-codecommit,Git,Amazon Web Services,Ssh,Aws Codecommit,我按照文档中的步骤创建和克隆了CodeCommit存储库(根据) 我还验证了我正在使用正确的私钥和公钥(根据) 我的ssh配置文件配置正确(请参阅) 用户附加了AWSCodeCommitFullAccess策略(包括CodeCommit:GitPush操作) 我可以成功克隆并拉取存储库,但是当我尝试推送提交时,会收到以下消息: You have successfully authenticated over SSH. You can use Git to interact with AWS Co
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.
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.
我使用的是Ubuntu 16.04和git版本2.7.4
GIT\u TRACE\u数据包的输出=true GIT\u TRACE=2 GIT\u CURL\u VERBOSE=1 GIT\u SSH\u COMMAND=“SSH-v”GIT push:
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.
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.
15:14:19.048714 git.c:369跟踪:内置:git'push'
15:14:19.049478 run command.c:369 trace:run_命令:“ssh-v”“awsgit”“git receive pack”“\''''/v1/repos/hsm'\''
15:14:19.050040运行命令。c:228跟踪:exec:'/bin/sh'-c''ssh-v“$@”''ssh-v''awsgit''git接收包'\''/v1/repos/hsm'\'''
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2,OpenSSL 1.0.2g 2016年3月1日
debug1:正在读取配置数据/home/daniel/.ssh/config
debug1:/home/daniel/.ssh/config第21行:为awsgit应用选项
debug1:读取配置数据/etc/ssh/ssh\u config
debug1:/etc/ssh/ssh\u配置第19行:应用*
debug1:连接到git-codecommit.ap-southerast-2.amazonaws.com[103.8.175.151]端口22。
debug1:已建立连接。
debug1:identity file/home/daniel/.ssh/keys/awsgit/awsgit类型1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/daniel/.ssh/keys/awsgit/awsgit证书类型-1
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
调试1:远程协议版本2.0,远程软件版本AWSCodeCommit VHVLLCAYYBKDW4GMJAXNYAWMZOXNDOWNSARMDAWMLPFICBGVY3JQS8ZWUJKQYKZ8FFRYB9BCPQRK5NPAEGEOK
调试1:不匹配:AWSCodeCommit VHVLLCAYYBKDW4GMJAXNYAWMZOXNDOWNSARMDAWMLPFICBGVY3JQS8ZWUJKQYKZ8FFRYB9BCPQRK5NPAEGEOK5IMVGVTXRVQ1VZQWZCMUC2 AXM1WLFSZ9SOXCTHY0UE9NUWT0UWJUAVU9
debug1:向git codecommit.ap-southest-2.amazonaws.com:22验证为“APKAJ…[修订]”
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:算法:diffie-hellman-group-exchange-sha256
debug1:kex:主机密钥算法:ssh-rsa
debug1:kex:server->client cipher:aes128 ctr MAC:hmac-sha2-256压缩:无
debug1:kex:client->server cipher:aes128 ctr MAC:hmac-sha2-256压缩:无
debug1:SSH2_MSG_KEX_DH_GEX_请求(2048据我所知,这个问题与ssh设置或git本身无关
这可能是一个远程获取,但您是否可以检查是否有任何shell初始化脚本,如.bashrc、.profile、.bash_登录等。。
这可能是失败的原因,请尝试暂时禁用/注释这些文件
否则,您是否可以通过运行
GIT\u TRACE\u PACKET=true GIT\u TRACE=2 GIT\u CURL\u VERBOSE=1 GIT push ssh-v
无论出于何种原因,您的git客户端版本似乎正在发送命令:
git接收包“/v1/repos/hsm”
我自己做了一个冗长的推送,我发现:
git接收包“/v1/repos/MyRepoName”
请注意,您的客户端似乎发送的是空格字符而不是连字符。这向我表明,您正在使用的版本中可能存在错误?我建议尝试更新到git客户端的最新版本
编辑:
可能尝试强制您的git客户端使用正确的命令。使用用于receivepack操作的命令编辑git配置:
git config --edit --global
然后,在您的遥控器(可能是来源?)下,添加:
不确定ssh是否是问题所在,但我通常只执行ssh复制id@
请确保您正在尝试推入未经授权的分支。也许您应该创建自己的分支,以便将代码推入其中!我已克隆并尝试推入master,并尝试推入新分支,但均无效。据我所知没有设置分支级别的授权限制。感谢您的考虑!要获得详细的调试输出,您可以尝试git config core.sshCommand“ssh-v”吗我已经在问题中添加了ssh-v输出。您找到解决方案了吗?我也有同样的问题,但只针对我的一些用户和克隆repo。他们可以使用MFA+HTTPS进行克隆,但ssh不会出现与您相同的错误。如果您能提供帮助,请提前感谢。奇怪的是,我已经更新到git 2.13.0,客户端仍然发送“git rec”我已经更新了问题中的输出。我已经在Ubuntu 16.04和Git 2.7.4上测试了这一点,它默认生成了预期的“Git receive pack”。但是,我能够使用我的配置值强制它使用“Git receive pack”,但以同样的方式失败。你应该看看你是否有receivepack='Git receive pack'set在全局或本地git配置中的任何位置。如果这样做,删除它应该可以解决问题。如果仍然看不到它,请尝试编辑全局git配置并强制它使用正确的命令。要执行此操作,请执行以下操作:git config--edit--global[remote“origin”]receivepack='git-receive-pack'我已经清除了所有的初始化脚本,并在问题中包含了额外的详细内容,我仍然得到相同的输出。如果它与脚本不一致,并且repo名称hsm是正确的(如上所述)然后必须是权限。我知道您正确地进行了身份验证并设置了权限,但是服务器上可能存在交互式shell权限或本地权限问题var/empty,如下所示:还有这个。祝您解决这个问题,好运,我已尽了最大努力。