Last active
July 7, 2019 11:13
-
-
Save rtomaszewski/3327482 to your computer and use it in GitHub Desktop.
Example script written in python that executes remotely commands over ssh
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('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