Last active
May 19, 2017 08:34
-
-
Save yuuichi-fujioka/364c7880e6b24e09b67feb006e4aa27c to your computer and use it in GitHub Desktop.
ssh with paramiko +α
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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