Permission Denied (publickey)

Had the same issue.

I had multiple public keys in my ~/.ssh/ directory: ~/.ssh/, ~/.ssh/, ~/.ssh/

I checked my public key in my SSH Keys settings section und and it matches my key. So I thought everything should be fine. But still got the Permission denied error when try to push initial project.

Finally the problem was in my ~/.ssh/config file, where I wrongly put these lines:

    # gitlab

            Preferredauthentications publickey
            IdentityFile ~/.ssh/id_rsa

Changed the IdentityFile to ~/.ssh/id_rsa.gitlab and sure it worked!

If you’re running gitlab locally under the docker and run the container with port forwarding (e.g 2224:22) and tried every thing from internet, just try this:

Host gitlab.local
    Preferredauthentications publickey
    IdentityFile ~/.ssh/id_rsa_gitlab_local
    Port 2224

With Port option your git commands will be addressed right to the gitlab container
Instead of gitlab.local you can use any domain or IP address

1 Like

this already solve my problem for case like this, but can i expect the default gitlab creation is pointing to https by default?

This is not the first time i face push failure