多个rsa密匙对分别对应不同的git账号
-rw-rw-r-- 1 vagrant vagrant 789 Feb 8 14:04 authorized_keys-rw-rw-r-- 1 vagrant vagrant 272 Feb 9 15:30 config-rw------- 1 vagrant vagrant 3247 Feb 9 13:20 id_rsa-rw------- 1 vagrant vagrant 3243 Feb 9 07:33 id_rsa_backlog-rw-r--r-- 1 vagrant vagrant 742 Feb 9 07:33 id_rsa_backlog.pub-rw------- 1 vagrant vagrant 3243 Feb 9 07:28 id_rsa_github-rw------- 1 vagrant vagrant 748 Feb 9 07:28 id_rsa_github.pub-rw------- 1 vagrant vagrant 3243 Feb 9 14:54 id_rsa_oschina-rw------- 1 vagrant vagrant 750 Feb 9 14:54 id_rsa_oschina.pub-rw------- 1 vagrant vagrant 748 Feb 9 13:20 id_rsa.pub-rw-r--r-- 1 vagrant vagrant 2654 Feb 9 15:14 known_hosts
建立config文件
vim config
编辑内容如下
#oschina Host oschina HostName git.oschina.net User git PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_oschina#githubHost github HostName github.com User git PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa
测试结果如下:
vagrant@homestead:~$ ssh -T git@githubHi KingSamuel! You've successfully authenticated, but GitHub does not provide shell access.
vagrant@homestead:~/.ssh$ ssh -T git@oschinaWelcome to Git@OSC, Samuel!