Skip to content

Instantly share code, notes, and snippets.

@copyleftdev
Last active August 29, 2015 14:02
Show Gist options
  • Save copyleftdev/0b482ff8f3976291b555 to your computer and use it in GitHub Desktop.
Save copyleftdev/0b482ff8f3976291b555 to your computer and use it in GitHub Desktop.
Python SHH
import paramiko
cmd = "uname -r"
host = 'dev'
user = 'username'
passwd = 'password'
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=user,password=passwd)
stdin, stdout, stderr = ssh.exec_command(cmd)
#stdin.write(passwd + '\n')
stdin.flush()
print stdout.readlines()
ssh.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment