如何使用 ssh 凭证连接到 AWS CodeCommit?

问题描述 投票:0回答:4

使用 ssh 连接到 CodeCommit 时遇到问题。

看来我做了所有需要的事情。生成 key ,给予他访问权限,为具有代码提交角色的用户放入 AWS IAM 公钥。在本地计算机上创建配置文件。答案总是:

$ ssh git-codecommit.us-east-2.amazonaws.com
[email protected]: Permission denied (publickey).

这是详细的 ssh:

ssh -v git-codecommit.us-east-2.amazonaws.com
OpenSSH_8.5p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021
debug1: Reading configuration data /home/edopc/.ssh/config
debug1: /home/edopc/.ssh/config line 1: Applying options for git-codecommit.*.amazonaws.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/50-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /home/edopc/.ssh/config
debug1: /home/edopc/.ssh/config line 1: Applying options for git-codecommit.*.amazonaws.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/50-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: Connecting to git-codecommit.us-east-2.amazonaws.com [52.95.17.51] port 22.
debug1: Connection established.
debug1: identity file /home/edopc/.ssh/codecommit type 0
debug1: identity file /home/edopc/.ssh/codecommit-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.5
debug1: Remote protocol version 2.0, remote software version AWSCodeCommit U2F0LCAyMiBNYXkgMjAyMSAxNjowNDowOSArMDAwMFjNE4tTOciz86teVxk/4lERVeKLS9FdeSxYQXNw3s8tUj
debug1: compat_banner: no match: AWSCodeCommit U2F0LCAyMiBNYXkgMjAyMSAxNjowNDowOSArMDAwMFjNE4tTOciz86teVxk/4lERVeKLS9FdeSxYQXNw3s8tUjRTVkFCRVlTWHpNMjBLNnFzNXRuMG8vTElFWCtzSHg5T29MVDc2YUNUakk9
debug1: Authenticating to git-codecommit.us-east-2.amazonaws.com:22 as 'APKA5S53BOD356YJBIJT'
debug1: load_hostkeys: fopen /home/edopc/.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: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes256-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes256-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_GROUP received
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: SSH2_MSG_KEX_DH_GEX_REPLY received
debug1: Server host key: ssh-rsa SHA256:3lBlW2g5xn/NA2Ck6dyeJIrQOWvn7n8UEs56fG6ZIzQ
debug1: load_hostkeys: fopen /home/edopc/.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 'git-codecommit.us-east-2.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /home/edopc/.ssh/known_hosts:1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /home/edopc/.ssh/codecommit RSA SHA256:R3h4w103OgUGoySJKnFe5rxeqU0gB7nEuQW0zH8uD9E explicit agent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/edopc/.ssh/codecommit RSA SHA256:R3h4w103OgUGoySJKnFe5rxeqU0gB7nEuQW0zH8uD9E explicit agent
debug1: send_pubkey_test: no mutual signature algorithm
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
amazon-web-services ssh aws-codecommit
4个回答
5
投票

OpenSSH 的最新版本默认删除了不太安全的算法。 CodeCommit 尚不支持最新推荐算法。

通过添加如下部分来编辑 ssh 的 .config 文件:

Host git-codecommit.*.amazonaws.com
  User REDACTED
  HostKeyAlgorithms +ssh-rsa
  PubkeyAcceptedAlgorithms +ssh-rsa

这将使 ssh 能够在 CodeCommit 中使用“ssh-rsa”算法。

请注意,无需像某些人建议的那样更改 id_rsa/id_rsa.pub 文件以使用不同的密钥类型。密钥交换算法已弃用。大的 RSA 密钥很笨重,但仍然足够安全。


3
投票

对于我的 mac osx 10.13:我认为这可以解决它。

Host git-codecommit.us-east-2.amazonaws.com
    PubkeyAcceptedKeyTypes=+ssh-rsa 
    HostKeyAlgorithms=+ssh-rsa
    User ***
    IdentityFile ~/.ssh/id_rsa


0
投票

只需按照此 AWS doc 中的说明进行操作即可。会起作用的。


0
投票

我写了一篇文章,解决尝试通过 SSH 连接时发生的一些 AWS CodeCommit 错误。

https://medium.com/stackademic/aws-codecommit-error-access-denied-not-authorized-to-perform-gitpull-7bb7e0f7e3f8

© www.soinside.com 2019 - 2024. All rights reserved.