While copying files (scp) to Amazon EC2 instance, got the following error:
$ scp ~/Downloads/pcre-8.31.tar.gz -i /Users/khanna/Downloads/k2.pem firstname.lastname@example.org:/tmp
Permission denied (publickey).
The error message is not that intuitive to debug but after some researching it turned out that the order of arguments was incorrect. This fixes that:
$ scp -i /Users/khanna/Downloads/k2.pem ~/Downloads/pcre-8.31.tar.gz email@example.com:/tmp