Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29253

How to copy files/directories remotely from linux to windows on AWS EC2 instance using Python?

$
0
0

I am trying to copy directories from linux server to windows machine where both of these are AWS EC2 instances using Python but couldn't do that.

I tried scp command which seems not working on AWS instances, also tried using sftp client of paramiko module in python which is alos not working and throwing access error for windows destination location path.

localpath = 'D:/Temp'
remotepath = '/home/temp'
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=HOST,port=PORT,username=USERNAME,key_filename=KEY)
sftp=ssh.open_sftp()
sftp.put(localpath,remotepath)
sftp.close()
ssh.close()

Following is the error:

Error:
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    sftp.put(localpath,remotepath)
  File "C:\Python27\lib\site-packages\paramiko\sft
    with open(localpath, "rb") as fl:
IOError: [Errno 13] Permission denied: 'D:\\Temp'

Viewing all articles
Browse latest Browse all 29253

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>