0

I have my own gitlab account, and I can ssh to it. I can pull and push to it, no problem. This problem popped up when I tried to ssh clone a private repo which I have access to (I have the credentials). I generated and added ssh key to this account. Configured git globally to reflect the username and email of this new account. And even set them in windows credential manager for gitlab. But the weird thing is I can't still do ssh clone. When I do ssh -T git@gitlab.com I am greeted with my old account. I don't know what else I have to do to ssh clone from this new account.

1 Answers1

1

@bk2204 you are a lifesaver. I created config file inside ~/.ssh and added the following according to one suggestion from the link you provided:

# Default Gitlab
Host gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa

# Work Gitlab
Host work.gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/work_rsa

And it worked, as I wanted it to. Many thanks!!!

  • 3
    I'd reccomend using also `IdentitiesOnly yes` to avoid having the agent try a bunch of keys before the right one. See https://stackoverflow.com/questions/4565700/how-to-specify-the-private-ssh-key-to-use-when-executing-shell-command-on-git/11251797#11251797 – ffflabs Apr 22 '19 at 23:30
  • @ffflabs thanks ! Which I could upvote your comment more, thanks, worked for me. – Janpan Jan 20 '21 at 20:58