Skip to content

Instantly share code, notes, and snippets.

@bot11
Created July 14, 2014 05:26
Show Gist options
  • Save bot11/8d6d3e8486a9cb1a7172 to your computer and use it in GitHub Desktop.
Save bot11/8d6d3e8486a9cb1a7172 to your computer and use it in GitHub Desktop.
paramiko scp
__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