I am trying to use fabric to automate some administrative work that I am doing on a couple of servers. The general flow is the following:
- SSH with local user
- run:
sudo su -
to become root (providing local user password again) - Do the work as root :)
Unfortunately using run('sudo su -')
blocks execution of the scripts and allows user input. When I type exit
or Ctrl+D
the scipt resumes, but without root privileges.
I have seen a similar problem in Switching user in Fabric but I am restricted to sudo su -
because I am not allowed to change the /etc/sudoers
file which contains the following line:
localuser ALL = /usr/bin/su -
I browsed the source of fabric trying to find a workaround but with no success.
sudo_prefix='su - -c '
as described in that post requires the root password. If I usesudo_prefix='sudo su - -c '
I get this error messageSorry, user localuser is not allowed to execute '/usr/bin/su - -c /bin/bash -l -c pwd' as root on hostname.
– Barbieshell=False
seems to have no effect. Settingpty=False
returns the errorsudo: no tty present and no askpass program specified
– Barbie