Question

Can't npm install GitHub Repository - Get error git@github.com: Permission denied (publickey).

Hi Everyone!

I have been trying to figure out how to successfully install an npm package hosted on my Github account. It works locally on my mac but not from my Digital Ocean Droplet.

Here are the guides I have looked at it and tried: https://www.digitalocean.com/community/questions/permission-denied-publickey-using-git-from-digitalocean-console-forge-user

https://stackoverflow.com/questions/57808112/digitalocean-and-github-permission-denied

and several others!

Nothing works.

I regenerated new keys and uploaded them to GitHub but still nothing.

The command I am trying to run is:

npm install git+ssh://github.com/mujibsardar/nodebb-theme-askavan.git

I get:

35 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "git+ssh://github.com/mujibsardar/nodebb-theme-askavan.git"
36 verbose node v10.16.0
37 verbose npm  v7.18.1
38 error code 128
39 error command failed
40 error command git --no-replace-objects ls-remote ssh://git@github.com/mujibsardar/nodebb-theme-askavan.git
41 error git@github.com: Permission denied (publickey).
41 error fatal: Could not read from remote repository.
41 error
41 error Please make sure you have the correct access rights
41 error and the repository exists.
42 verbose exit 128

here are the permissions on my .ssh directory

drwx------ 2 root root 4096 Feb  1 21:21 .
drwx------ 9 root root 4096 Jun 18 22:34 ..
-rw-r--r-- 1 root root  103 Jun 19 16:33 authorized_keys
-rw------- 1 root root  411 Jun 18 18:59 id_ed25519
-rw-r--r-- 1 root root  103 Jun 18 18:59 id_ed25519.pub
-rw-r--r-- 1 root root 1548 Jun 18 18:26 known_hosts

My apologies if I missed to share something more fundamental. Any help would be highly appreciated!


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.

Bobby Iliev
Site Moderator
Site Moderator badge
June 20, 2021
Accepted Answer

Hi there @avansardar,

As discussed below, the fix was to upgrade the Node version from v10.x to v14.x as per this tutorial here.

The setup actually looks all good. What I could suggest is to try to SSH to GitHub by adding the -v argument to see some debug messages:

ssh -vvv git@github.com

Feel free to share the output here.

Alternatively, I would recommend using HTTP rather than SSH to install the package:

npm install git+https://github.com/mujibsardar/nodebb-theme-askavan.git

Let me know how it goes! Regards, Bobby

Try DigitalOcean for free

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

Sign up

Featured on Community

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