3

There are SFTP client to do the work manually, like this one: http://comtechies.com/how-to-upload-and-download-files-in-amazon-aws-ec2-instance.html

But, wondering how can it be done using Python in Python Script ? (apart from creating a batch file...)

EDIT: As mentionned, in the comments, this one exists : SFTP in Python? (platform independent)

But, it does not solve the issue of authentification with EC2 Instance.

Thanks, regards

Community
  • 1
  • 1
tensor
  • 3,088
  • 8
  • 37
  • 71

1 Answers1

1

This may help you :-

Create the server by creating the reservation :-

reservation = conn.run_instances(my_AMI,
        key_name = key,
        instance_type ='c4.xlarge',
        security_group_ids = security_group,
        placement = 'region' )

instance = reservation.instances[0]

print colored("Instance IP: %s" % instance.ip_address, 'yellow')

Then later you could scp the file :-

instance_IP = instance.ip_address
os.system('scp -i %s %s ubuntu@%s:~/destinationFolder' % (key_path,rgs_tarpath, instance_IP) )
Piyush S. Wanare
  • 4,703
  • 6
  • 37
  • 54