Ssh Socket Closed . Wanted An Interactive Ssh Shell Automation For Linux Box
Ssh Socket Closed . Wanted an Interactive Ssh shell automation for Linux Box import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoA
Solution 1:
Two things that you'll find useful:
exec_command
takes an optional argument ofget_pty
. You can use it like this:(stdin, stdout, stderr) = ssh.exec_command("sudo ls", get_pty = True)
Throw the password into
stdin
, with a line return and flush to make sure it gets delivered. This ensures it receives the password if it asks (you could do something more sophisticated to check if it actually asked or not... simply throwing it in always hasn't caused problems for me, yet.)stdin.write('passwd' + '\n') stdin.flush()
Taken together, those should fix your sudo
over paramiko
issues.
Solution 2:
Most of the time this problem is related to Time Between sending two commands. I had this problem.when i used "time.sleep(X)" between my commands , this problem gone.
Post a Comment for "Ssh Socket Closed . Wanted An Interactive Ssh Shell Automation For Linux Box"