Search code examples
sshgitlabcertificate

gitLab: certificat issue, missing ssh public key


i can't get a point and understand how it works and what is necessary to do.

I have an account by GitLab and successfully generated private and public certificate in order to provide access to it. I done all steps as describes the https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair . Now i decided to create a new project and synchronize the state between gitLab project and one i created local by me. Because i have access to machine, which i used to create both certificate, i simply copied the public key from one machine (located in ~/.ssh folder) to current machine i am working in (in ~/.ssh folder). But it doesn't take any effect. I can't even execute the git clone command.

~> git clone git@gitlab.com:[myUser]/[myProject].git
Cloning into 'gate-controller'...
git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

i tried to figure out the reason and executed

~> ssh -vT git@gitlab.com

but to be a honest i can't interpret that response. I don't see in response any reference to my public keys file in ssh folder.

Could you please support me to solved the issue and understand, what is the problem ?

many thanks in advance

UPDATE: this is the out of ssh -vT git@gitlab.com

this is conthent of ssh folder in VM i try to working on. The yellow line is just copied pub certificate from other VM


Solution

  • You need the private key on any machine you're attempting to pull/push from. When authenticating with a service that has your public key (which any git service like Github, Gitlab, etc. will have) you need to use your private key when authenticating.

    You can read more about ssh (which git uses when you don't use HTTPS auth) and PKI (Public Key Infrastructure) here https://www.ssh.com/pki/