gitlab with two ssh keys not connecting (config updated)

可紊 提交于 2019-12-24 02:12:17

问题


I have a gitlab account on my mac which has the neccessary ssh key on it for my work account. I am trying to set up gitlab for all my personal projects. I have created a personal account on gitlab and created a ssh key.

I have edited the config file in ~/.shh/ to look like this

Host markgameforeverything.gitlab.com
    HostName gitlab.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/personal.pub

Host markbreadcreative.gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa.pub

however I am not able to

git pull

as I get this error

GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists

if I type

ssh -T git@gitlab.com

I get

Welcome to GitLab, *my work account welcome*!

(the wrong account) Can anyone suggest any further steps I may take or see an error in my code?


回答1:


Check how does your .git/config look like. I guess you don't have there url starting with markbreadcreative. and markgameforeverything. prefixes.

To get your setup working, you need to modify the lines in your repo from

url = git@gitlab.com:whatever.git

to

url = git@markbreadcreative.gitlab.com:whatever.git
url = git@markgameforeverything.gitlab.com:whatever.git

respectively depending on which account you want to use. You can check your configuration using:

ssh -T git@markbreadcreative.gitlab.com
ssh -T git@markgameforeverything.gitlab.com

(should return different results). If not, post a verbose log from such commands (ssh -vvvT git@markgameforeverything.gitlab.com).



来源:https://stackoverflow.com/questions/35297959/gitlab-with-two-ssh-keys-not-connecting-config-updated

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!