I try setup git dependencies in package.json:
"dependencies": {
"myLib": "git+ssh://git@domain.com:user/myLib.git"
}
When I do sudo npm install I got errors:
Warning: Permanently added the RSA host key for IP address 'myIp' to the list of known hosts.
Permission denied (publickey).
Allthough I can clone successfully the same lib to that machine:
git clone git@domain.com:user/myLib.git
So I have valid ssh keys.
My os is OsX but I have the same problem on linux.
I should run npm install without sudo.
If can not, then change permissions for node.js apps folder:
sudo chown -R `whoami` ~/pathToAll/node/apps.
So git ssh dependencies work well in package.json
Here is a solution that allows for continued use of sudo npm install.
Add the following to a text file /root/.ssh/config:
Host domain.com
User git
Port 22
Hostname domain.com
IdentityFile "/home/user/.ssh/id_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
StrictHostKeyChecking no
This configuration references the original key file even while using the sudo command for things like sudo npm install.