Last active
October 16, 2016 09:13
-
-
Save maldevel/870e87774e203c8fbeb440e54b7aeeb4 to your computer and use it in GitHub Desktop.
Perform commands over ssh with Python
This file contains hidden or 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 | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
ssh.connect('example.com', username='username', password='password') | |
stdin, stdout, stderr = ssh.exec_command('ls') | |
lines = stdout.readlines() | |
for line in lines: | |
if line.strip(): | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment