delameh
By:
delameh

ERROR **Permission denied (publickey). fatal: Could not read from remote repository** While running: "git push production master"

September 12, 2017 397 views
Nginx Git Ubuntu 16.04

Hello, guys.

It is my first time deploying by myself. So I am following this tutorial: https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/.
I am having an issue when pushing to the server. I receive the error below when I run "git push production master". Any idea?

Permission denied (publickey).
fatal: Could not read from remote repository.

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

Thank you in advance.
Shola

2 Answers

Google the 2 errors you stated and come back if you find nothing at all.

  • I would not have posted about this challenge if I could figure it out googling. I did find a few cases but could not resolve the issue, and that is why I posted about it here.

Hello Shola,

Permission denied (publickey).
fatal: Could not read from remote repository.

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

This simply means that you don't have the right permissions to ssh into your droplet. As it looks, you are missing a private ssh key. Have you setup your droplet with an RSA key? This private ssh key also has to be available on the development server before you can push things.

If you have multiple production servers or servers secured with a SSH key, you could use a ssh configuration like this:

Host            gitserv
    Hostname        remote.server.com
    IdentityFile    ~/.ssh/id_rsa.github
    IdentitiesOnly yes # see NOTES below

I hope this is helpfull. If you need anything else don't hesistate to ask me.

  • Hi CrypticDesigns,

    Yes, you are perfectly right. I Although, I did set up an RSA key on the local machine but the private key is unavailable on the server, which explains the cause of the challenge. I will look for a detailed tutorial online to get it done.
    For now, I could push to the server using "sudo git .........". But, please could you explain the implication of that? I suspect there may be some security concern here.

    Thank you very much for helping out.

Have another answer? Share your knowledge.