Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano with only 'sudo su - user' allowed

I'm trying to do an uncomplicated Rails/Capistrano deployment to a remote server. Unfortunately I can't get sudo to run correctly out of the box. I need to deploy here:

drwxr-xr-x 2 user   www       4096 Sep 28 15:05 my_app_dir

and sudoers has been set up to allow me to run sudo su - user and that's it.

Some attempts to coax this into working from deploy.rb:

set :use_sudo, true
set :sudo, 'sudo su - user'  # fails due to bad su syntax, -c is inserted after user
set :sudo, 'sudo -u user'  # fails because it's not set up
set :sudo, 'sudo su - user -c' # also bad syntax
set :sudo_prompt, ''

I gather than the best options are to either:

  1. Enable password-less sudo (recommended here)
  2. Enable sudo -u user, which should work with set :sudo, 'sudo -u user'

Any ways to make this work as is?

like image 301
jordanpg Avatar asked Nov 12 '22 21:11

jordanpg


1 Answers

Is your user that you're trying to use added to the sudoers cfg on the server? Try this

run "#{sudo :as => 'bob'} mkdir /path/to/dir"

source

like image 66
Máté Avatar answered Dec 06 '22 10:12

Máté