Download/Upload a File/Directory from AWS EC2 Instance to Local Machine.
Published in
1 min readFeb 4, 2021
Here , we will learn about how to exchange files between local machine and AWS EC2 Instance.
Related Links
- https://medium.com/@rahul26021999/how-to-create-a-ubuntu-20-04-server-on-aws-ec2-elastic-cloud-computing-5b423b5bf635
- https://medium.com/@rahul26021999/how-to-connect-to-ec2-instance-aws-from-windows-ubuntu-da97c0cc9c8
Download a file from AWS EC2 Instance
By running this command you can download a file from AWS EC2 instance to your local machine.
$ sudo scp -i path/to/mykey.pem user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/filename path/local/directory
Download a directory from AWS EC2 Instance
By running this command you can download a folder from AWS EC2 instance to your local machine.
$ sudo scp -i path/to/mykey.pem -r user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/directory path/local/directory
# Hack 1 : To download folder from AWS EC2, You can archive it and then download it like a file .
Upload a file to AWS EC2 Instance from local
By running this command you can upload a file from your local machine to AWS EC2 instance.
$ sudo scp -i path/to/mykey.pem path/local/filename user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/directory
Upload a directory to AWS EC2 Instance from local
By running this command you can upload a folder from your local machine to AWS EC2 instance.
$ sudo scp -i path/to/mykey.pem -r path/local/directoryName user@ec2–49–252–8–93.ap-south-1.compute.amazonaws.com:path/remote/directory