execute commands as su on remote server

Julio Oña thinmanj at gmail.com
Tue Aug 18 14:41:10 CEST 2015


try to use http://www.fabfile.org/

look at:

sudo() call has the posibility to change to another user besides root, with:

with settings(sudo_user='mysql'):
    sudo("whoami") # prints 'mysql'

El lun., 17 de ago. de 2015 a la(s) 11:07 p. m., Chris Angelico <
rosuav at gmail.com> escribió:

> On Tue, Aug 18, 2015 at 12:57 PM,  <harirammanohar159 at gmail.com> wrote:
> > I need to execute commands after doing su to other user on remote
> server(not sudo which doesn't require password) how i can achieve this
> using python?
> > I googled and came to know that its not possible, so just for
> confirmation asking again, is it possible ?
> Ultimately, this isn't a Python question, it's a systems
> administration one. You want a way to execute commands as a specific
> user, triggering them remotely. There are basically two ways you can
> do this: either you provide some form of credentials (this is what
> sudo does), or you elevate the entire management process. The latter
> option is far FAR easier (running it as root if you might need to go
> to any different user, or as that specific user if you'll only ever
> use one), but then you have to ensure, in some way, that your Python
> program can't be compromised.
> Python has nothing to do with any of this. If you want to manage
> elevation using sudo, Python can invoke sudo in a subprocess. If you
> want to elevate the Python process and then simply invoke something
> directly, Python won't even be aware of it.
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150818/31987d74/attachment.html>

More information about the Python-list mailing list