It is required that your private key files are NOT accessible by others ubuntu

C++
$ sudo chmod 600 /path/to/my/key.pem
chmod 400 {keyfile}.pem is what amazon instructed and it works.


Source

Also in C++: