我有以下问题。作为我工作的一部分,我处理多个 AWS 账户,每个账户都有一个单独的 AWS CodeCommit 存储库和特定于账户的 IAM 用户(这会导致不同的用户 ID)
我想找到一种方法来配置我的 ssh 以根据存储库访问不同的帐户
目前它工作正常,因为我的配置文件如下所示:
Host git-codecommit.*.amazonaws.com
User APKAEIBAERJR2EXAMPLE
IdentityFile ~/.ssh/codecommit_rsa
我需要的是能够添加使用不同帐户的不同存储库,这样我就不必每次从一个项目切换到另一个项目时都编辑配置文件,即
#Use this User ID and ssh-key for repo A
Host git-codecommit.*.amazonaws.com
User IAMUSERIDFROMACCOUNT1
IdentityFile ~/.ssh/codecommit_rsa
#Use this User ID and ssh-key for repo B
Host git-codecommit.*.amazonaws.com
User IAMUSERFROMANOTHERAWSACCOUNT
IdentityFile ~/.ssh/codecommit_rsa
我到处浏览都没有找到正确的答案。预先感谢您对此主题的任何帮助。
Regards
你走在正确的道路上:-)。您需要修改配置文件并为每个用户/身份文件对创建一个主机条目。例如:
Host git-account1
User IAMUSERIDFROMACCOUNT1
IdentityFile ~/.ssh/codecommit
HostName git-codecommit.us-east-1.amazonaws.com
Host git-account2
User IAMUSERIDFROMACCOUNT2
IdentityFile ~/.ssh/codecommit
HostName git-codecommit.us-east-1.amazonaws.com
Host git-account3
User IAMUSERIDFROMACCOUNT3
IdentityFile ~/.ssh/codecommit
HostName git-codecommit.us-east-1.amazonaws.com
你的 git 命令行看起来像这样:
git 克隆 ssh://git-account1/v1/repos/AccountOneRepo
git 克隆 ssh://git-account2/v1/repos/AccountTwoRepo
git 克隆 ssh://git-account3/v1/repos/AccountThreeRepo
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)