i pretty new python programming, part of learning had decided start coding simple daily task save sometime, i'm done part of script see big challenge in executing , because need execute remote server sudo user access. need is,
login remote system. run sudo su - user(no need of password ssh key based login) run code. logout result assigned varible. need end result of script stored in variable can use verification.
thanks answers guys. fabric worked me, below code snippet.
from fabric.context_managers import settings fabric.api import * settings(host_string='username@host',user='runcommand_user'): run('command')
but before using make sure have set sudo access below in host (runcommand_user) nopasswd: all
u can login host , execute 'sudo -l' check if have access mentioned above
Comments
Post a Comment