首页 > 其他 > 详细

Git配置多ssh密钥

时间:2019-01-11 16:38:15      阅读:158      评论:0      收藏:0      [点我收藏+]

在工作过程中,我们经常需要在不同代码托管平台上的仓库编写代码,比如公司内部使用的gitlab仓库和自己的github仓库。因此,配置多个ssh密钥方便拉取和提交代码。

生成ssh密钥

ssh-keygen -t rsa -f gitlab_rsa   #公司仓库
ssh-keygen -t rsa -f github_rsa   #个人仓库

添加ssh私钥

ssh-agent bash   #刷新
ssh-add ~/.ssh/gitlab_rsa
ssh-add ~/.ssh/github_rsa

配置config文件,具体配置内容如下:

touch ~/.ssh/config   #生成配置文件
#gitlab
Host serverIP  #IP地址或域名
Port 22 
HostName serverIP #与Host相同
PreferedAuthentications publickey
IdentityFile /home/yourname/.ssh/gitlab_rsa #密钥路径名
User login name     #该服务器上的用户名

#github
Host github.com
Port 22
HostName github.com
PreferedAuthentications publickey
IdentityFile /home/username/.ssh/github_rsa
User your github username

在各代码托管平台上添加ssh公钥

Git配置多ssh密钥

原文:https://www.cnblogs.com/loveBBZ/p/10255747.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!