具体步骤
- 首先cd到
~/.ssh
路劲下面 - 查看有没有
config
文件存在,如果没有的话 touch 创建一个 touch config
- 下文中有三个账号分别对应的是三个不同的git服务器,最终配置好的config文件的代码如下
Host git@oss.navercorp.com
HostName git@oss.navercorp.com
User ren.jinbo
IdentityFile ~/.ssh/id_oss_rsa
Host git@git.coding.net
HostName git@git.coding.net
User jimboRen
IdentityFile ~/.ssh/id_rsa_code
Host git@github.com
HostName git@github.com
User goldWave
IdentityFile ~/.ssh/id_rsa—a_github
Host
为账号对应的服务器地址,HostName
可以相同 , User
为 当前账户下的用户名,IdentityFile
为对应的私钥地址(如果不会生成,可以参考这里)- 最终整个 .ssh的文件夹概况为下图: