如何设置系统,以便可以从两个来源(github和aws CodeCommit)进行克隆,而无需进行每次切换的更改?
创建或编辑~/.ssh/config
文件
使内容为:
Host git-codecommit.*.amazonaws.com
User APKAS2GIPODK7YOUR-ID
IdentityFile ~/.ssh/codecommit_rsa
Host github.com
User your_github_username
IdentityFile ~/.ssh/id_rsa
我假设您已经按如下方式生成了github ssh密钥,id_rsa
并按id_rsa.pub
如下所示生成了aws密钥以创建codecommit_rsa
文件,即与githubid_rsa
文件不同的文件
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/durrantm/.ssh/id_rsa): /home/durrantm/.ssh/codecommit_rsa
#
# **NOTE** As shown, change above filename from id_rsa to codecommit_rsa !!!
# This avoids over-writing your github id_rsa keys (so you can have both)
# So don't just press return for defaults !!!
#
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/durrantm/.ssh/codecommit_rsa.
Your public key has been saved in /home/durrantm/.ssh/codecommit_rsa.pub.
现在我可以克隆任一回购
$ git clone ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/HellowBlueGreenWorld
Cloning into 'HellowBlueGreenWorld'...
remote: Counting objects: 6, done.
Receiving objects: 100% (6/6), 759 bytes | 759.00 KiB/s, done.
...
$ git clone [email protected]:durrantm/setups.git
Cloning into 'setups'...
remote: Enumerating objects: 9, done.
...
Receiving objects: 100% (1739/1739), 1.21 MiB | 4.52 MiB/s, done.
...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句