解决方案
ssh-keygen -t rsa -C "jiangph1001@qq.com" -f ~/.ssh/id_rsa_2016
ssh-keygen -t rsa -C "jiangph1001@foxmail.com" -f ~/.ssh/id_rsa_1001
执行完以后,会在.ssh
目录下生成两对公私钥
$ ls
id_rsa_1001 id_rsa_1001.pub id_rsa_2016 id_rsa_2016.pub known_hosts
然后使用ssh-add
添加密钥到ssh-agent中
ssh-add ~/.ssh/id_rsa_2016
ssh-add ~/.ssh/id_rsa_1001
在.ssh
目录下新建config文件
# 2016
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_2016
# 1001
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_1001