# 生成密钥(多用户重复以下操作)
$ ssh-keygen -t rsa -C "zhangsan"
# 指定目录路径生成的密钥文件
Enter file in which to save the (/root/.ssh/id_sa):[自定义路径:/c/Users/Administrator/.ssh/id_rsa_gitee]
Enter passphrase (empty for no passphrase):[输入密码]
Enter same passphrase again:[再次输入密码]
# 此时~/.ssh目录中会生成两个文件分别:id_rsa_gitee、id_rsa_gitee.pub
# 复制密钥(打开id_rsa_gitee.pub复制密钥)
# 把复制的密钥内容,添加到对应Git平台->SSH公钥
# 在~/.ssh目录新建一个config文件,添加如下内容(其中Host和HostName填写git服务器的域名或IP,IdentityFile指定私钥的路径)
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
# gitblit
Host 192.168.0.101:10101
HostName 192.168.0.101:10101
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitblit
# ssh测试
ssh -T git@gitee.com
ssh -T ssh://zhangsan@192.168.0.101:29418