1. 生成对应的私钥公钥
git默认访问的.ssh目录(默认就存在当前登录用户文件夹.ssh目录)
- gitee
ssh-keygen -t rsa -C xxx@qq.com -f ~/.ssh/id_rsa_gitee
- github
ssh-keygen -t rsa -C xxx@qq.com -f ~/.ssh/id_rsa_github
2. 把对应的公钥配置到github和gitee的ssh上
3. 在.ssh目录创建config文本文件,并完成相关配置
HostName 这个是真实的域名地址
IdentityFile 这里是id_rsa的地址
PreferredAuthentications 配置登录时用什么权限认证--可设为publickey,password publickey,keyboard-interactive等
User 配置使用用户名
#gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
User xxx@99.com
#github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
User xxx@99.com
4. 测试
$ ssh -T git@gitee.com
Hi HappyMa! You've successfully authenticated, but GITEE.COM does not provide shell access.
``