Strider-CD / strider

Open Source Continuous Integration & Deployment Server
http://strider-cd.github.io/
4.59k stars 432 forks source link

Can't install private git+ssh npm dependency #408

Closed mattpardee closed 10 years ago

mattpardee commented 10 years ago

When running, I get this error when trying to install private repos:

npm ERR! [link to private repo] Permission denied (publickey).

I've seen this previously, it's not using my system's default SSH key. Any ideas?

microadam commented 10 years ago

How are you running Strider? Have you just cloned the git repository onto machine or are you running it through Docker?

You will need to ensure that whatever user is running the Strider process has an SSH key assigned to them and that SSH key has access to your private git repositories.

mattpardee commented 10 years ago

I installed via npm, not through docker. Running the npm install process in my own terminal works. I'm running strider in the same user space.

Also it's worth noting these npm refs are in this form: "reponame": "git+ssh://git@github.com:repoowner/reponame.git#commithash"

microadam commented 10 years ago

On the project you are having issues with, drag in the "Custom Scripts" module.

In the prepare phrase enter "whoami" and try running a build.

You should see the output in the terminal. Can you confirm that the user that is displayed by the "whoami" command is the user you expect?

Also, the user that is running Strider, does it have a private key in its user HOME dir?

mattpardee commented 10 years ago

Yep, same user. My ~/.ssh dir has the keys I use for interacting with github. Is it possible the npm install command being kicked off by strider isn't inheriting the same environment I'm using as the user I'm logged in as?

mattpardee commented 10 years ago

I'm guessing this is related. https://github.com/Strider-CD/strider/issues/381

niallo commented 10 years ago

Hi Matt,

What happens if you run env as a custom script? Possibly $HOME isn't set?

mattpardee commented 10 years ago

Good guess, but the script reports that HOME is set to /Users/msp. It's interesting to me that strider can clone the original repo, which is private, but not the ones in NPM referenced by git+ssh. Is strider using its own version of NPM?

mattpardee commented 10 years ago

When I go into the temporary directory in /Users/msp/.strider/data strider has created to house the cloned repo, and run npm install myself, it works fine. Running ls -al shows I am the owner of all the files contained therein.

niallo commented 10 years ago

How does env in custom scripts differ from env in a regular shell? If nothing is sensitive in it, please post it here.

mattpardee commented 10 years ago

Huge thanks to @Niallo for helping debug this and publishing the fix in the runner core, our private repos can be pulled in now.