如何使用 ssh 凭证连接到 AWS CodeCommit?
How to connect to AWS CodeCommit with ssh credentials?
使用 ssh 连接到 CodeCommit 时遇到问题。
看来我该做的都做了。生成密钥,给他访问权限,为具有代码提交角色的用户放入 AWS IAM 公钥。在本地机器上创建配置文件。答案总是:
$ ssh git-codecommit.us-east-2.amazonaws.com
APKA5S53BOD356YJBIJT@git-codecommit.us-east-2.amazonaws.com: 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.
APKA5S53BOD356YJBIJT@git-codecommit.us-east-2.amazonaws.com: Permission denied (publickey).
只需按照此 AWS doc 中的说明进行操作即可。它会起作用。
对于我的 mac osx 10.13:我想这可能会解决它。
Host git-codecommit.us-east-2.amazonaws.com
PubkeyAcceptedKeyTypes=+ssh-rsa
HostKeyAlgorithms=+ssh-rsa
User ***
IdentityFile ~/.ssh/id_rsa
最近发布的 OpenSSH 默认删除了不太安全的算法。 CodeCommit暂不支持最新的推荐算法。
通过添加如下部分来编辑 ssh 的 .config 文件:
Host git-codecommit.*.amazonaws.com
User REDACTED
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
这将使 ssh 能够将“ssh-rsa”算法与 CodeCommit 结合使用。
请注意,无需像某些人建议的那样更改 id_rsa/id_rsa.pub 文件以使用不同的密钥类型。密钥交换算法已弃用。大型 RSA 密钥笨重但仍然足够安全。
使用 ssh 连接到 CodeCommit 时遇到问题。
看来我该做的都做了。生成密钥,给他访问权限,为具有代码提交角色的用户放入 AWS IAM 公钥。在本地机器上创建配置文件。答案总是:
$ ssh git-codecommit.us-east-2.amazonaws.com
APKA5S53BOD356YJBIJT@git-codecommit.us-east-2.amazonaws.com: 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.
APKA5S53BOD356YJBIJT@git-codecommit.us-east-2.amazonaws.com: Permission denied (publickey).
只需按照此 AWS doc 中的说明进行操作即可。它会起作用。
对于我的 mac osx 10.13:我想这可能会解决它。
Host git-codecommit.us-east-2.amazonaws.com
PubkeyAcceptedKeyTypes=+ssh-rsa
HostKeyAlgorithms=+ssh-rsa
User ***
IdentityFile ~/.ssh/id_rsa
最近发布的 OpenSSH 默认删除了不太安全的算法。 CodeCommit暂不支持最新的推荐算法。
通过添加如下部分来编辑 ssh 的 .config 文件:
Host git-codecommit.*.amazonaws.com
User REDACTED
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
这将使 ssh 能够将“ssh-rsa”算法与 CodeCommit 结合使用。
请注意,无需像某些人建议的那样更改 id_rsa/id_rsa.pub 文件以使用不同的密钥类型。密钥交换算法已弃用。大型 RSA 密钥笨重但仍然足够安全。