How to files exchanged between AWS EC2 and your local machine
Copying files from local to EC2
- We will use
scp, this tool is Secure Copy or SCP is a means of securely transferring files between two machines on a network. SCP uses SSH for improved security and will prompt you if it needs a password or passphrase for authentication.
- You'll need the
scptool and your
key_name.pemfile to make this.
- By using these two resources, you can define which files do you want to copy between your EC2 instance and your local machine.
- This is an alternative if you use Filezilla for the file exchanging.
How to transfer files from your local machine to an EC2 instance
Run this script on your local machine
$ scp -i /path/to/your/key_name.pem /path/of/yout/local/file/to/copy firstname.lastname@example.org:path/where/ to/save/the/file
How to transfer files from an EC2 instance to your local machine
Run this script on your local machine.
$ scp -i /path/to/your/key_name.pem email@example.com:path/where/the/file/exists /your/local/directory/to/save/the/file
- Depending on the operative system, you should change the
server_username. For an Ubuntu instance, you could use
- Make sure the user has to read permissions on the server directory.
- If you want to transfer all the files on a directory, use an asterisk
*on the path where all the files exist. See the example below
$ scp -i /path/to/your/key_name.pem \ firstname.lastname@example.org:~/* \ /your/local/directory/to/save/the/files