密钥生成和配置
ssh 生成密钥对
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -f id_rsa.github -C "sshgithub"
ssh-keygen -t rsa -b 4096 -f id_rsa.codingnet -C "sshcodingnet"
添加公钥
将生成的 id_rsa.github.pub
和 id_rsa.codingnet.pub
公钥分别添加至 github 和 coding net 账户中
密钥配置
在 ~/.ssh
目录下,添加如下配置文件,文件名 config
# github
Host github.com
HostName github.com
AddKeysToAgent yes
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.github
User [UserName]
# coding net
Host e.coding.net
HostName e.coding.net
AddKeysToAgent yes
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.codingnet
User [UserName]