ssh-keygen -t rsa -C “painarthur@gmail.com” -f ~/.ssh/id_rsa_github_painarthur
ssh-keygen -t rsa -C “paincupid@hotmail.com” -f ~/.ssh/id_rsa_github_paincupid
ssh-keygen -t rsa -C “paincupid@hotmail.com” -f ~/.ssh/id_rsa_oschina
添加
ssh-add ~/.ssh/id_rsa_github_painarthur
ssh-add ~/.ssh/id_rsa_github_paincupid
ssh-add ~/.ssh/id_rsa_oschina
如果执行ssh-add时提示”Could not open a connection to your authentication agent”,可以现执行命令:
$ ssh-agent bash
在bash下的话直接touch config 新建文件config即可,用NotePad之类的文本工具打开
config文件
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github_painarthur
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github_paincupid
# oschina
Host git.oschina.net
HostName git.oschina.net
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_oschina
测试
ssh -t git@github.com
ssh -T git@git.oschina.net
上面第二个github的帐号没试,貌似相同的网站下不同的帐号,还需要其它处理。请参考:http://www.cnblogs.com/xjnotxj/p/5845574.html
第一个和第三个没有问题,亲测