sshpermissionsgitlabssh-keygen

Gitlab SSH Key | must the ssh have the same username as gitlab account


Problem

Does the 'user@host' of the id_rsa.pub need to match with the actual machine username - host and then with the username in Gitlab?

Example:

So as you can see, my user in Ubuntu is mark and the ssh rsa key generated has a mark@JOHNDOE as last domain. But should it be john.doe@JOHNDOE instead (both in Ubuntu user and in the ssh pub key)?

And let's say that for some reason I cannot change the user in my Ubuntu machine.

I honestly think the answer is no and the issue is on my user in Gitlab that has some missing permissions or some network related problem, and I'm just paranoid but just to make sure that is not related with the ssh keys. I think the ssh key just need to match the one in Gitlab and the username in the key has nothing to do (because actually, you can change it with command -C "john.doe@JOHNDOE" which is a Comment and anyway it still gives me errors. But again I have the doubt is ALSO the username of the Ubuntu must be john.doe

Command run / Troubleshot

Creating ssh

ssh-keygen -t rsa -b 2048

Add SSH

cat ~/.ssh/id_rsa.pub 
# Then copy the key to gitlba key - etc.. 

Also try do

eval $(ssh-agent -s)
ssh-add -D
ssh-add ~/.ssh/id_rsa.pub

Error

Do a git clone

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

Connecting

ssh -T git@gitlab.example.com
banner exchange: Connection to [here the IP but removed] port 22: Connection timed out


Solution

  • Ok so the problem is the VPN software that I used. As @Raya pointed out the answer to my question is:

    No, the user in the ssh public key does not matter

    As soon as I changed the VPN it start to work therefore the problem was Network related

    Will auto-post the answer and mark as accepted, but won't close the question so if anyone has better information can add it.