Am like to figure out in Fabric https://www.fabfile.org/index.html , framework to run commands on the remote machine via SSH.
Via Getting Started, I could do to connect, running commands via user with connected by; and run commands with sudo by the Responder.
But I ran into problem, that I need to run utility, which requires password after root/sudo password - it utility sqlcmd, it CLI-client to MSSQL database and i have password authentication there. A tried add second Responder, but it doesn't work. Also i have did forget why i wasn't using -P option for sqlcmd.
So, I wanted to use sudo method of Connection, but cannot find where to specify password for sudo.
thats example am partially work. Error screen presents.
import getpass
from fabric import Connection, Config
import fabric.config
import paramiko
import getpass
import logging
logging.basicConfig(level=logging.DEBUG)
c = Connection(host = '93.156.248.1', user = 'nnnnn'
, connect_kwargs={ "password": "1234"}
#, config=config
)
c.run('ls -a') #this works
c.sudo('iostat', kwargs={ "password": "H9!nrsnrsnrs"}) #this not works
c.close()
what's problem? Please help.
import getpass
from fabric import Connection, Config
import fabric.config
import paramiko
import getpass
import logging
logging.basicConfig(level=logging.DEBUG)
sudo_pass = "1234"
config = Config(overrides={'sudo': {'password': sudo_pass}})
c = Connection(host = '93.156.228.8', user = 'nrv'
, connect_kwargs={ "password": "123"}
, config=config
)
c.run('ls -a')
c.sudo('iostat')
this works, problem that is not written in doc, wherefor i seen then and tried in my code