I have user and group test:test

When I'm at the shell logged in as test I can do git pull origin master and npm install and it works.

I also have a cgi script that gets called from Caddy (a webserver). It does the same thing as the same user but yet it gets permission errors.

How do I debug this. What commands will show me why I'm getting permission when in the shell but not when running from a spawned script?

The errors in the script are

Could not create directory '/home/test/.ssh'.

/home/test/.ssh already exists and already has keys etc. They work fine from the shell

for npm it gets these errors

npm ERR! Linux 4.4.0-87-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! path /home/test/.npm/_locks
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/home/test/.npm/_locks'

But yet again, running from the shell no errors.

I added id to the script so I could see what user the script is running as. It prints

uid=1000(test) gid=1000(test) groups=1000(test),27(sudo)

Which is the exact same thing it prints when I type id in the shell

What else should I be looking for?


The problem was caddy is run from systemd and it was set to


which means /home/test is off limits to the spawned script. Not sure what the correct solution is but at least tracked down the source of the issue

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.