I have an EC2 instance running and I am able to SSH into it.
However, when I try to rsync, it gives me the error Permission denied (publickey).
The command
copy file from local machine to server
rsync -avz -e "ssh -i /path/to/key.pem" /path/to/file.txt @:/path/to/directory/
copy file from server to local machine
rsync -avz -e "ssh -i /path/to/key.pem" @:/path/to/directory/file.txt /path/to/directory/