我有多個 github 帳號,分別設定了不同的 SSH key,one_rsa 和 two_rsa 那麼,在對 git 專案進行操作時,如何確保不衝突呢?
one_rsa
two_rsa
走同样的路,发现不同的人生
使用 ssh config(ssh_config Recipes). 在 .ssh 目录下新建一个 config 文件,配置對應不同 Host 使用不同的 key. 例如:
.ssh
config
Host gitcafe.xxx HostName gitcafe.com User git IdentityFile ~/.ssh/id_rsa_gitcafe_xxx Host gitcafe.yyy HostName gitcafe.com User git IdentityFile ~/.ssh/id_rsa_gitcafe_yyy Host github.xxx HostName github.com IdentityFile ~/.ssh/id_rsa_github_xxx # 此行是代理配置,请无视 ProxyCommand ~/.ssh/socksproxywrapper.sh %h %p
例如 id_rsa_github_xxx 是你在 github 上 xxx 用戶的 key, 就可以使用
id_rsa_github_xxx
github
xxx
git clone git@github.xxx:xxx/project.git
這樣的方式來拉取 github 上的物品。
ssh 可以設定host,在~/.ssh/config裡面吧
使用 ssh config(ssh_config Recipes). 在
.ssh
目录下新建一个config
文件,配置對應不同 Host 使用不同的 key. 例如:例如
id_rsa_github_xxx
是你在github
上xxx
用戶的 key, 就可以使用這樣的方式來拉取
github
上的物品。ssh 可以設定host,在~/.ssh/config裡面吧