1 生成github 公钥私钥
ssh-keygen -t rsa -C “youremail@your.com” -f ~/.ssh/github-rsa
2 生成gitee的公钥私钥
ssh-keygen -t rsa -C “youreamil@your.com” -f ~/.ssh/gitee-rsa
3 上面两步生成两对公钥私钥,用到 -f 参数来指定文件不同的名字,然后在~/.ssh 目录下 新建config 文件配置密钥对对应的host(私钥放到github或者gitee,公钥放在本地,但是本地有两个公钥,根据提交的host的不同区分)
#github Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github-rsa
#gitee Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee-rsa
4 以上就ok了,然后把代码从远程仓库clone下来,赠送添加,修改,移除远程的源的命令
#先查看远程的仓库地址
git remote -v
#添加远程的仓库的地址
git remote add origin git@gitee.com:your/your.git
#移除远程仓库地址
git remote remove orgin