国内访问github,要么访问不上,要么慢慢慢,所以决定用gitee。1,生成ssh-key
解决同一台服务器部署多个放在gitee上的应用,需要配置不同的ssh-key对应不同的环境。
ssh-keygen -t rsa -C 'youremail@your.com' -f ~/.ssh/xxx_rsa
【gitee配置多个SSH-Key】
![gitee配置多个SSH-Key](https://img.it610.com/image/info9/097065a1d02e4e73a2ace2a4a59ee017.png)
文章图片
2,将xxx_rsa.pub中的内容添加到自己的gitee部署公钥中。
cat ~/.ssh/xxx_rsa.pub
![gitee配置多个SSH-Key](https://img.it610.com/image/info9/04a15fde49374b288410105d3e10c00a.png)
文章图片
3,添加到公钥
![gitee配置多个SSH-Key](https://img.it610.com/image/info9/acc2836a54bd4095b5ed9fa420ea4839.jpg)
文章图片
4,进入到~/.ssh目录下新建config文件,用编辑器打开config文件并添加内容
# xxx项目
Host gitee-xxx.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/xxx_rsa
![gitee配置多个SSH-Key](https://img.it610.com/image/info9/81a056093b434cfa8b1476a35cbec9c6.jpg)
文章图片
5,测试是否部署成功
ssh -T git@gitee-dev.com
![gitee配置多个SSH-Key](https://img.it610.com/image/info9/03f60a7393334bf18bef4ea22d19fa97.jpg)
文章图片
6,Git命令clone项目
git clone git@gitee-xxx.com:leadson/xxx.git