Created
July 14, 2014 05:26
-
-
Save bot11/8d6d3e8486a9cb1a7172 to your computer and use it in GitHub Desktop.
paramiko scp
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
__author__ = 'bot11' | |
import sys, paramiko | |
hosts = {'host1': '192.168.1.1', | |
'host2': '192.168.1.2'} | |
port = 22 | |
username = 'user' | |
password = 'password' | |
for host, ip in hosts.items(): | |
try: | |
transport = paramiko.Transport((ip, port)) | |
transport.connect(username=username, password=password) | |
sftp = paramiko.SFTPClient.from_transport(transport) | |
sftp.put('sshd_config', '/etc/ssh') | |
sftp.close() | |
transport.close() | |
except: | |
e = sys.exc_info() | |
print e | |
continue | |
finally: | |
print "------------------------Done-----------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment