Skip to content

Instantly share code, notes, and snippets.

@rtomaszewski
Last active July 7, 2019 11:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtomaszewski/3327482 to your computer and use it in GitHub Desktop.
Save rtomaszewski/3327482 to your computer and use it in GitHub Desktop.
Example script written in python that executes remotely commands over ssh
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() )
ssh.connect('5.79.4.10', username='root', password='7raW6nS6Krttest')
stdin, stdout, stderr = ssh.exec_command('echo text on stdout stream; echo text on stderror stream 1>&2')
print("reading outputs from the remote command")
for l in stdout :
print("stdout : %s" % l.strip())
for l in stderr:
print("stderr : %s" % l.strip())
ssh.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment