Fabric: using a local command

I want to execute a command that requires sudo on the local machine. So, as the documentation suggests, I used a local command, but she was asked to enter a password. How can i avoid this? Is there a place where I can save my local computer password?

local('sudo /etc/init.d/tomcat6 start',capture=True)
+5
source share
3 answers

Check the command visudo, which will allow you to edit the file /etc/sudoers, in which you can define the users, commands and password requirements on the machine (for example, the mlzboy user does not need to enter a password to execute /etc/init.d/tomcat6). Remember that this can create a security problem.

Shipbuilders Guide

+4

, :

echo "password\n" | sudo -S /etc/init.d/tomcat6 start

sudo man:

-S (stdin) sudo . .

+4

If you want to use sudo but in loopback ip:

from fabric.api import sudo,env
env.hosts =['127.0.0.1']
sudo('aptitude search fabric')

There is no need to edit sudoers if you have an ssh server running locally.

+1
source

All Articles