Skip to content

Instantly share code, notes, and snippets.

@nibocn
Created February 6, 2015 09:43
Show Gist options
  • Save nibocn/933187978204e38f5477 to your computer and use it in GitHub Desktop.
Save nibocn/933187978204e38f5477 to your computer and use it in GitHub Desktop.
git使用多个私钥文件
  • ~/.ssh目录下创建config文件,添加如下内容:
Host coding-nibome
        HostName coding.net
        User git
        IdentityFile ~/.ssh/nibome

Host:别名可随意定义,后面会使用到;

HostName:实际的域名;

User:用户,

IdentityFile:私钥文件路径

配置完成后,具体clone远程仓库:

git clone coding-nibome:nibome/xxx.git

其中coding-nibome就是上面定义的Host,对照一般的方式git clone [email protected]/nibome/xxx.git,就不难看出根据找到的Host节点,然后用其对应的UserHostName进行替换。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment