Skip to content

Instantly share code, notes, and snippets.

@samson-sham
Last active June 2, 2022 02:29
Show Gist options
  • Save samson-sham/d409b6b868acc5e6fff24c4bdae112ad to your computer and use it in GitHub Desktop.
Save samson-sham/d409b6b868acc5e6fff24c4bdae112ad to your computer and use it in GitHub Desktop.
Setup AWS CodeCommit

Create AWS IAM User

  • Create IAM User, select exisiting policy with respective CodeCommit permission

Create SSH credential

  • AWS CodeCommit SSH does not support ED25519 cryptography, has to use RSA
ssh-keygen -t rsa -b 4096 -C "why-dont-support-ed25519"

Add SSH credential to AWS

  • Inside the created User, in "Security credentials" tab, upload SSH public key to "SSH keys for AWS CodeCommit"
  • Copy the public key into textfield, submit
  • A new row will be created, with a generated SSH Key ID, which to be used in the following step

Config SSH

  • In .ssh/config
Host git-codecommit.*.amazonaws.com
  AddKeysToAgent yes
  UseKeychain yes
  User %COPY_FROM_GENERATED_SSH_KEY_ID%
  IdentityFile ~/.ssh/codecommit

Test

ssh git-codecommit.ap-northeast-1.amazonaws.com

A successful result will be like this

This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'git-codecommit.ap-northeast-1.amazonaws.com' (RSA) to the list of known hosts.
You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.ap-northeast-1.amazonaws.com closed by remote host.
Connection to git-codecommit.ap-northeast-1.amazonaws.com closed.

Reference

AWS Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment