Question

I'm currently using Capistrano to deploy my web application which works like a charm.

In my new project I must execute a command from sudo /bin/bash shell.

Is it possible for Capistrano to login to the machine as user X, run sudo /bin/bash, enter the password and then execute a command in the sudo shell? If yes, could you please provived me with an example.

With regards

jakob

Was it helpful?

Solution

Is there a specific reason you need to be in a root shell rather than executing the command with sudo? If executing a command with sudo, you can simply sudo 'command' instead of run 'command'.

I did a little experimentation to try to get a root shell with capistrano without logging into the server directly as root, and wasn't able to make much progress.

If running with sudo won't work, please update your question to let us know why and maybe we can help you find a workaround for it.

Update:

After playing around a little more, I found that you can execute an individual command (or string of commands) in a root shell by doing something like sudo '/bin/bash -c "whoami"'. It's getting an interactive root shell that's tricky.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top