2

Getting permission denied error for a local repo, which I can clone successfully, however getting error for npm install:npm install

npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://git@stash.company.com:2222/castor/module-name.git
npm ERR!
npm ERR! git@stash.company.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MOEL3\AppData\Roaming\npm-cache\_logs\2018-03-08T18_12_33_006Z-debug.log

However, I have to put my password each time I do a git command regarding the remote repo pull, push etc... would that be the reason? howto solve this problem?

Muhammad Bekette
  • 1,396
  • 1
  • 24
  • 60

1 Answers1

0

Recently came across this issue, so frustrating...

I could git clone a private repo no problems, but as soon as I tried to npm install a package through Visual Studio Code, it fell over on what looked like an authentication error.

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

What fixed it for me was opening Sublime Text as Administrator, locating the ssh_config file in the C:ProgramFiles/Git/etc/ssh/ folder, opening this in the Admin sublime window, and adding this at the bottom

HOST github.com
IdentityFile /c/Users/me/.ssh/id_rsa

It turned out that npm install was looking in the root folder for my key, not in the home folder. Telling it to take the key from the identity in my user folder solved the issue.

Hope this may help someone else.

IfElseTryCatch
  • 483
  • 9
  • 12