Mic*_*ant 5 git github amazon-web-services
如何设置我的系统,以便可以从两个来源(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
Run Code Online (Sandbox Code Playgroud)
我假设您已经生成了 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.
Run Code Online (Sandbox Code Playgroud)
现在我可以克隆任一存储库
$ 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 git@github.com:durrantm/setups.git
Cloning into 'setups'...
remote: Enumerating objects: 9, done.
...
Receiving objects: 100% (1739/1739), 1.21 MiB | 4.52 MiB/s, done.
...
Run Code Online (Sandbox Code Playgroud)