Question

Digital Ocean Droplet and GitHub

I have followed the tutorial

https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

But I cannot get it to work I keep getting the following message

git push production master root@MYSITE.com: Permission denied (publickey). fatal: Could not read from remote repository.

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


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
May 5, 2023
Accepted Answer

Hello @squarenet

It seems you’re experiencing issues with git push and receiving a Permission denied (publickey) error message. This issue is generally due to the server not recognizing your SSH key.

To resolve this issue, please follow these steps:

  1. Make sure you have the correct SSH key in the ~/.ssh/id_rsa.pub file on your local machine.
  2. Check if your public SSH key is in the ~/.ssh/authorized_keys file on your server, and if it’s not, add it to the file (you can use ssh-copy-id command to do that).
  3. Ensure that the file permissions for the ~/.ssh directory (700) and ~/.ssh/authorized_keys file (600) are correct on the server.

For more information on working with SSH keys, check out this DigitalOcean guide on Adding SSH Keys.

Hope that this helps!

KFSys
Site Moderator
Site Moderator badge
May 4, 2023

Heya,

From the error provided, it seems like your public key doesn’t have access to your github repository.

You’ll need to add your server’s public key to your repository in order for you to be able to access it from the server.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel