To connect to a remote server via SSH usually you’ll have to specify the public key file doing something like this:

ssh -i ~/.ssh/server_key.pem user@1.2.3.4

Then if you don’t have the proper permissions in the server_key.pem file you’ll get an error like the following one:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for '/home/user/.ssh/server_key.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/user/.ssh/server_key.pem": bad permissions
user@1.2.3.4: Permission denied (publickey).

To fix it you’ll have to set the correct permissions running the following command:

sudo chmod 600 ~/.ssh/server_key.pem

This will leave the key file with just read and write permissions for the owner.