New to Python:
I have below block of code that is supposed to loop on remote hosts.
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.load_system_host_keys()
ssh.connect(host, 22, username, password, timeout=5)
stdin, stdout, stderr = ssh.exec_command('sudo hostname')
I get:
sudo: no tty present and no askpass program specified
I tried
stdin, stdout, stderr = ssh.exec_command('sudo -S hostname')
AND
stdin, stdout, stderr = ssh.exec_command('sudo hostname', get_pty=True)
But the code is getting stock forever (not working).
Any suggestions?