Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Last active May 19, 2017 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuichi-fujioka/364c7880e6b24e09b67feb006e4aa27c to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/364c7880e6b24e09b67feb006e4aa27c to your computer and use it in GitHub Desktop.
ssh with paramiko +α
import paramiko
c = paramiko.client.SSHClient()
c.load_system_host_keys()
c.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
c.connect('192.168.0.1', username='ubuntu', password='password',
sock=paramiko.ProxyCommand('ssh -W 192.168.0.1:22 -w 120 10.0.0.1'))
_in, _out, _err = c.exec_command('ls -la')
print _out.read()
import paramiko
c = paramiko.client.SSHClient()
c.load_system_host_keys()
c.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
c.connect('192.168.0.1', username='ubuntu', password='password')
t = c.get_transport()
s = t.open_session()
_in, _out, _err = s.exec_command('ls -la')
print _out.read()
# Ctrl-c
s.send("\x003")
import paramiko
c = paramiko.client.SSHClient()
c.load_system_host_keys()
c.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
c.connect('192.168.0.1', username='ubuntu', password='password')
_in, _out, _err = c.exec_command('ls -la')
print _out.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment