GIT配置码云、github
前言
因为github有时候连接不上。所以想同时使用gitee。通过配置ssh key
一、生成SSH keys
输入下面的命令。默认三次回车就可以。不设置密码 github
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "501870769@qq.com"
gitee
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "501870769@qq.com"

二、gitee、github配置ssh key
1.查看生成的秘钥
cd ~/.ssh
ll
cat id_rsa.gitee.pub
效果图 
2.网站配置ssh key
登录码云网站。点击设置-SSH公钥。标题自己取个名字。将上述步骤1的id_rsa.gitee.pub内容copy到公钥 效果图
 github同理  
3.创建配置文件
通过pwd获得路径。在电脑上打开  在目录下创建无后缀的config文件  编辑config文件。输入以下内容
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.gitee
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.github
注意 : id_rsa.github 同本地文件名一直。使用公钥名字
4.最后测试下
ssh -T git@github.com
ssh -T git@gitee.com
 出现上述字样即可!
|