08.21.2019

Sync file from local or VPS to EC2 using .pem key

How to use sync file from local or VPS to standard Amazon Web Services instances that uses .PEM key instead of username/password authentication

Sometime we need to sync file from local or VPS to EC2 instance which uses .pem file for authentication.
Standard AWS EC2 instance require .pem key to SSH instead of username / password

$ chmod 0400 pemfile.pem
$ rsync -rave "ssh -i pemfile.pem" /path/to/local/files ec2-user@EC2_IP_OR_HOSTNAME:/path/to/remote/files


Make sure /path/to/remote/files was own by ssh user (in this case ec2-user).
If not, simply run

$chown ec2-user: /path/to/remote/files

Hope it help!

Leave a comment