-
-
Save justinpawela/3a7056cd592d688425e59de2ef6f1da0 to your computer and use it in GitHub Desktop.
# This file is: ~/.ssh/config | |
# You may have other (non-CodeCommit) SSH credentials stored in this | |
# config file – in addition to the CodeCommit settings shown below. | |
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file! | |
# Credentials for Account1 | |
Host awscc-account1 # 'awscc-account1' is a name you pick | |
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region | |
User A1EXAMPLE01234567891 # UserID as provided by IAM Security Credentials (SSH) | |
IdentityFile ~/.ssh/account1-awsCC-rsa # Path to corresponding key file | |
# Credentials for Account2 | |
Host awscc-account2 | |
Hostname git-codecommit.us-east-1.amazonaws.com | |
User A2EXAMPLE01234567892 | |
IdentityFile ~/.ssh/account2-awsCC-rsa | |
# Credentials for Account3 | |
Host awscc-account3 | |
Hostname git-codecommit.us-east-1.amazonaws.com | |
User A3EXAMPLE01234567893 | |
IdentityFile ~/.ssh/account3-awsCC-rsa |
Amazing work! I wish AWS CodeCommit provided a simpler way to approach this (e.g. by including the repo name inside the hostname instead of path, so that we can define multiple keys per repo).
Nice gist
Thanks, this really helped me!
Kudos!
Thank you!
Thank you!!
Thank you!!
Thanks.
Cool! i love it! And bookmarked. I also suggested this to AWS to be adapted to their docs.
still works perfectly! thank you so much for keeping this live. it's a simple solution to a frustrating problem.
Excellent. So much better than commenting out all the time. Cheers!
Added update due to OpenSSH deprecating support for ssh-rsa. New flags are needed to connect with CodeCommit until they get the certificates updated. Changes in forked gist at https://gist.github.com/lonmiller/6f6c00400bf627642a3696dc575d2e6b.
Awesome... Thanks!
Cool! Thanks!
OMG Thank you ... most answers online don't address this issue correctly!
You are a life-saver!!!
Thanks. This is life saver
It saves my day
Bonus: added config for more accounts, each Host will be loaded itself config
.gitconfig
[includeIf "gitdir:~/"]
path = ~/.gitconfig-personal
exclude = ~/work/*
exclude = ~/code-commit/*
[includeIf "gitdir:~/work/"]
path = ~/work/.gitconfig-work
[includeIf "gitdir:~/code-commit/"]
path = ~/code-commit/.gitconfig-code-commit
[push]
autosetupremote = true
default = current
Or you can also use
git remote set-url origin <new-url>
to update an existing repo