I have a private repo that I want to install in my package.json file.
"private-module": "git+ssh://git@bitbucket.org:private/private-module.git"
By default npm uses your default private key. I want to be able to specify which ssh key npm should use when running npm install. Is there any way to do this?
Here are a few solutions:
Add an entry to your ~/.ssh/config. For example:
Host bitbucket.org
IdentityFile ~/.ssh/bitbucket_key
IdentitiesOnly yes
Use ssh-agent and add your key to the agent instance beforehand.
Use something like ssh-ident for choosing ssh agents and identities dynamically based on the current working directory or arguments passed to ssh-ident. As their readme states, you would typically alias ssh-ident to ssh so that it's automatically used everywhere.