Securely Transfer Files to and from an AWS EC2 Instance

AWS   Bash   SCP   SSH

Securely Transfer Files to and from an AWS EC2 Instance

To securely transfer files to and from an AWS EC2 instance, the SCP command is invaluable. It leverages SSH for encryption, ensuring your data’s security. To use SCP, you’ll need your EC2 instance’s SSH private key (your-ssh-key.pem).

Copying from EC2 to Your Mac:

scp -i "your-ssh-key.pem" ec2-user@your-ec2-ip:/remote/file/path ~/local/file/path

This command downloads a file from your EC2 to the current directory on your Mac.

Copying from Your Mac to EC2:

scp -i "your-ssh-key.pem" ~/local/file/path ec2-user@your-ec2-ip:/remote/file/path

This uploads a file from your Mac to a specified path on your EC2 instance.

Replace placeholder paths with actual file locations and your EC2’s IP address. This process ensures secure file transfer, utilizing your EC2’s SSH key for authentication

References