Created
November 26, 2016 12:55
-
-
Save mr-karan/273f2b6e1af6f29b7208a95568751a73 to your computer and use it in GitHub Desktop.
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 | |
ip='server ip' | |
port=22 | |
username='username' | |
password='password' | |
cmd='some useful command' | |
ssh=paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
ssh.connect(ip,port,username,password) | |
stdin,stdout,stderr=ssh.exec_command(cmd) | |
outlines=stdout.readlines() | |
resp=''.join(outlines) | |
print(resp) | |
stdin,stdout,stderr=ssh.exec_command('some really useful command') | |
outlines=stdout.readlines() | |
resp=''.join(outlines) | |
print(resp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment