同一台电脑使用多个ssh私钥配置不同的github账号

参考链接:https://medium.com/@xiaolishen/use-multiple-ssh-keys-for-different-github-accounts-on-the-same-computer-7d7103ca8693

 

1. 创建私钥

ssh-keygen -t rsa -b 4096 -C "my_work_email@my_company.com"

  

2. 编辑 ~/.ssh/config 文件

Host github.com
    HostName github.com
    User git
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa

# Work GitHub account
Host github.com-company
    HostName github.com
    User git
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa_xadl

 

3.克隆项目

用 github.com-company 替代克隆链接中的 github.com

git clone git@github.com-work:[my work GitHub group]/[my project].git
posted @ 2020-06-09 14:21  SurfUniverse  阅读(408)  评论(0编辑  收藏  举报