1、在C盘用户目录下.ssh文件夹下打开git的控制台,执行下面的命令
# [email protected]自己在github中配置的用户名
ssh-keygen -t rsa -C "[email protected]" -f "github_id_rsa"
ssh-keygen -t rsa -C "[email protected]" -f "gitee_id_rsa"
一个ssh秘钥的名称为github_id_rsa,一个为gitee_id_rsa。执行过程中,在提示
Enter passphrase (empty for no passphrase)和Enter same passphrase again 都按回车
生成的目录结构:
2、把公钥(gitee_id_rsa.pub,github_id_rsa.pub)中的内容分别复制到gitee和github的ssh keys中,以便进程远程连接
3、在.ssh目录下创建config文件解决ssh冲突
1、执行touch ~/.ssh/config创建config
2、执行命令vi config
,并在文件中添加如下内容
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
然后:wq保存退出
4、完成后在命令行测试,首次建立链接会要求信任主机
ssh -T [email protected]
ssh -T [email protected]
如果返回如下语句,则表示配置成功
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.