Created
August 23, 2011 06:59
-
-
Save jakubjedelsky/1164518 to your computer and use it in GitHub Desktop.
ssh & paramiko - základy
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
# http://www.minvolai.com/blog/2009/09/how-to-ssh-in-python-using-paramiko/ | |
import os | |
import paramiko | |
ssh = paramiko.SSHClient() | |
ssh.load_host_keys(os.path.expanduser(os.path.join('~', '.ssh', 'known_hosts'))) | |
# using ssh keys | |
key_filename = os.path.expanduser(os.path.join('~', '.ssh', 'id_dsa')) | |
ssh.connect('servername', username='username' key_filename=key_filename) | |
stdin, stdout, stderr = ssh.exec_command('ls -l /tmp') | |
print stdout.read() | |
ssh.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment