本地git 添加多个远程仓库

1、在本地找到,~/.ssh 文件夹

2、执行 ssh-keygen -t rsa -C "Winseek" -f "id-rsa-github"

3、生成了id-rsa-github和id-rsa-github.pub,copy id-rsa-github.pub

4、登录github,在setting里找到,SSH and GPG keys,新增ssh key 粘贴进去

5、在本地执行,ssh-add ~/.ssh id-rsa-githb

6、测试是否成功 ssh -T [email protected]

注意:

使用ssh-add 会存在一个坑,就是下次再重启电脑时,发现git连接不上了,这时需要配置config了

vi config

Host github.com

 User git

 Hostname github.com

 PreferredAuthentications publickey

 IdentityFile ~/.ssh/id-rsa-github

 

Host gitlab.com

 User git

 Hostname gitlab.com

 PreferredAuthentications publickey

 IdentityFile ~/.ssh/id-rsa-gitlab

猜你喜欢

转载自www.cnblogs.com/windseek/p/11042770.html
今日推荐