簡體   English   中英

如何使用 ssh 憑證連接到 AWS CodeCommit?

[英]How to connect to AWS CodeCommit with ssh credentials?

使用 ssh 連接到 CodeCommit 時出現問題。

看來我做了所有需要的事情。 生成密鑰,授予他訪問權限,為具有代碼提交角色的用戶放入 AWS IAM pubkey。 在本地機器上創建配置文件。 答案總是:

$ 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 文檔中的說明進行操作。 它會起作用的。

對於我的 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 能夠通過 CodeCommit 使用“ssh-rsa”算法。

請注意,無需像某些人建議的那樣更改 id_rsa/id_rsa.pub 文件以使用不同的密鑰類型。 密鑰交換算法已棄用。 大型 RSA 密鑰很笨重,但仍然足夠安全。

暫無
暫無

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

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