Created
December 13, 2016 08:43
-
-
Save Aeternam/39d307fdbf4bffded525c0bd24173a2e to your computer and use it in GitHub Desktop.
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 | |
import traceback | |
import os | |
import sys | |
try: | |
for env in TAIR_IP: | |
mykey = paramiko.RSAKey.from_private_key_file(os.path.expanduser('~/.ssh/id_rsa')) | |
t = paramiko.Transport((TAIR_IP[env][0], 22)) | |
t.connect(username='root', pkey=mykey) | |
\ | |
sftp = paramiko.SFTPClient.from_transport(t) | |
local_env_f_cur = LOCAL_CONF_FILE+'_'+env+'_cur' | |
#sftp.put(localpath=local_env_f_cur, remotepath=GROUP_CONF_FILE) | |
sftp.put(localpath=local_env_f_cur, remotepath='/tmp/') | |
sftp.close() | |
t.close() | |
os.remove(local_env_f_cur) | |
except Exception as e: | |
print "SSH error!" | |
print('*** Caught exception: %s: %s' % (e.__class__, e)) | |
traceback.print_exc() | |
try: | |
sftp.close() | |
t.close() | |
except: | |
pass | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment