- paramiko http://www.lag.net/paramiko/
- ssh module ( a wrapper for paramiko) http://stackoverflow.com/questions/1939107/python-libraries-for-ssh-handling
- pythion binding to C libssh library http://www.no-ack.org/2010/11/python-bindings-for-libssh2.html
- fabric http://docs.fabfile.org/en/1.4.3/index.html>
- python SSH module (base on the paramiko) http://pypi.python.org/pypi/ssh/1.7.11
http://pypi.python.org/pypi/paramiko/1.7.7.2
http://media.commandline.org.uk/code/ssh.txt
https://github.com/bitprophet/ssh
This is a simple python example as well.
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 | |
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() |
you should also do a
ReplyDeletessh.close()
at the end to close the connection.
Thanks for your comment! I've added it to the example code.
ReplyDeleteThanks so much. It works well
ReplyDelete