-
Goto your AWS IAM Console and create or modify a current IAM user (preferably the one you use to connect with your AWS CLI)
-
Goto Security Credentials -> Scroll down to SSH keys for AWS CodeCommit
-
Create a private/public ssh key on your local machine:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
-
Click on "Upload SSH Public Key" and paste in the contents of
~/.ssh/id_rsa.pub
into the textarea and save. -
Note the Access Key ID that was generated, it will be something like APKA********** this will be used as your User for SSH access
-
Navigate to the AWS CodeCommit Console and click on your repository (or create one)
-
Create a
~/.ssh/config
file with the following contents (modify for your setup/names):Host MyCodeCommit HostName git-codecommit.us-east-1.amazonaws.com User Your-IAM-SSH-Key-ID-Here IdentityFile ~/.ssh/id_rsa
Now you can connect to any repository within your AWS CodeCommit with:
git clone ssh://MyCodeCommit/v1/repos/my-repo-name-here
You can have multiple repositories in the ~/.ssh/config file with different custom "Host" names, just keep the "HostName" value to the appropriate AWS CodeCommit URL and you can access them via
git clone ssh://My-Custom-Name/v1/repos/my-repo
For example (~/.aws/config):
Host SomeRepo
HostName git-codecommit.us-east-1.amazonaws.com
User Your-IAM-SSH-Key-ID-Here
IdentityFile ~/.ssh/id_rsa
Host SomeOtherRepo
HostName git-codecommit.us-east-2.amazonaws.com
User Your-IAM-SSH-Key-ID-Here
IdentityFile ~/.ssh/id_rsa