Search code examples
gitdeploymentsshcapistrano

Capistrano deploy failing with scp: /tmp/<project_name>/git-ssh.sh: Permission denied


I'm tearing my hair out here. I assume the deploy user, in this case www-data, doesn't have sufficient privileges make the necessary directory. Or is this an SSH related problem?

I'm using Capistrano 3.5 to deploy onto Ubuntu 15.10.

Here's the full trace

00:00 git:wrapper
      01 mkdir -p /tmp/project_name/
    ✔ 01 [email protected]
(Backtrace restricted to imported tasks)
cap aborted!
scp: /tmp/project_name/git-ssh.sh: Permission denied

Tasks: TOP => git:check => git:wrapper
(See full trace by running task with --trace)
The deploy has failed with an error: scp: /tmp/project_name/git-ssh.sh: Permission denied

** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:  

  INFO ---------------------------------------------------------------------------
  INFO START 2016-05-18 17:34:33 +0100 cap production deploy
  INFO ---------------------------------------------------------------------------
  INFO [a283be11] Running /usr/bin/env mkdir -p /tmp/project_name/ as [email protected]
 DEBUG [a283be11] Command: /usr/bin/env mkdir -p /tmp/project_name/
  INFO [a283be11] Finished in 2.160 seconds with exit status 0 (successful).
 DEBUG Uploading /tmp/project_name/git-ssh.sh 0.0%

Edit for Kenster

on server ran

ls -lR /tmp/<project_name>

output

/tmp/<project-name>:
total 4
-rwxr-xr-x 1 root root 93 May 17 22:21 git-ssh.sh

Solution

  • In the end I just had to set the permissions for my deploy user 'www-data' on the git-ssh.sh file by running

       chown www-data /tmp/project_name/git-ssh.sh