Skip to content

Instantly share code, notes, and snippets.

@ulissescastro
Created November 18, 2014 01:39
Show Gist options
  • Select an option

  • Save ulissescastro/a6e5ad4b090f0903117e to your computer and use it in GitHub Desktop.

Select an option

Save ulissescastro/a6e5ad4b090f0903117e to your computer and use it in GitHub Desktop.
Fix Paramiko TTY (sudo)
#!/usr/bin/env python26
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='10.10.10.10', port=22, username='user', password='xxx')
chan = ssh.get_transport().open_session()
chan.get_pty()
chan.exec_command('sudo su -c "id"')
print(chan.recv(1024))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment