Mark Gilchrist
Mark Gilchrist

Reputation: 2032

gitlab with two ssh keys not connecting (config updated)

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 [email protected]

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?

Upvotes: 2

Views: 815

Answers (1)

Jakuje
Jakuje

Reputation: 25936

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 = [email protected]:whatever.git

to

url = [email protected]:whatever.git
url = [email protected]:whatever.git

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

ssh -T [email protected]
ssh -T [email protected]

(should return different results). If not, post a verbose log from such commands (ssh -vvvT [email protected]).

Upvotes: 3

Related Questions