Hi,
I was wondering if somebody can help.
I'm writing a python script to make a remote command but requires a sudo password. I got the following script but the password is not sendout it seems
thanks in advance for any assistance
I was wondering if somebody can help.
I'm writing a python script to make a remote command but requires a sudo password. I got the following script but the password is not sendout it seems
thanks in advance for any assistance
Code:
import paramiko
import SocketServer
import socket
import commands
import os
import time
ssh=paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect ('127.0.0.1','22','user','password')
chan = ssh.invoke_shell()
chan = ssh.get_transport().open_session()
chan.get_pty()
chan.exec_command('sudo ls /qp1/mo/script >>/home/user/dirout.test')
print(chan.recv(4096))
chan.send('password\n')
ssh.close()