我希望用户为不同的URL(git存储库)使用不同的AWS IAM帐户
我的ssh配置文件(做点工作):
Host git-codecommit.*.amazonaws.com/v1/repos/metro
User APKAJCGAGGG3PGQ5AAAA
IdentityFile ~/.ssh/id_rsa
Host git-codecommit.*.amazonaws.com/v1/repos/taxi
User APKAJCGAGGG3PGQ5BBBB
IdentityFile ~/.ssh/id_rsa
在添加第二个存储库之前,我使用了这个,但是现在第二个存储库使用了另一个AWS IAM:
Host git-codecommit.*.amazonaws.com
User APKAJCGAGGG3PGQ5AAAA
IdentityFile ~/.ssh/id_rsa
编辑
工作:
Host git-codecommit.eu-west-1.amazonaws.com
User APKAJCGAGGG3PGQ5AAAA
IdentityFile ~/.ssh/id_rsa
不起作用:
Host metro
Hostname git-codecommit.eu-west-1.amazonaws.com
User APKAJCGAGGG3PGQ5AAAA
IdentityFile ~/.ssh/id_rsa
Host taxi
Hostname git-codecommit.eu-west-1.amazonaws.com
User APKAJCGAGGG3PGQ5BBBB
IdentityFile ~/.ssh/id_rsa
答案 0 :(得分:3)
当您有多个ssh配置文件时,需要将其命名为“主机”。
您的〜/ .ssh / config看起来像这样:
Host metro
Hostname git-codecommit.us-east-1.amazonaws.com
User APKAJCGAGGG3PGQ5AAAA
IdentityFile "/Full/Path/To/Your/.ssh/id_rsa"
Host taxi
Hostname git-codecommit.us-east-1.amazonaws.com
User APKAJCGAGGG3PGQ5BBBB
IdentityFile "/Full/Path/To/Your/.ssh/id_rsa"
尽管AWS docs for setting up SSH to the CodeCommit repo表示主机名中该区域的通配符有效,但是当我有多个ssh配置文件时(这可能是我的本地设置阻止了此操作),这对我不起作用。使用多个配置文件时,您可能需要使用如上所述的实际区域。
设置好个人资料后,只需输入ssh
加上您设置的“主机”别名即可进行SSH。在上面的示例中,它将是ssh metro
或ssh taxi
,您将已连接。