If you received an error when login to AWS EC2 instance or any virtual machine using the PEM file by SSH command like below:
$ ssh -i ~/.ssh/your_pem_file.pem username@192.168.0.102 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/home/username/.ssh/your_pem_file.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/username/.ssh/your_pem_file.pem: bad permissions lab@10.10.20.11: Permission denied (publickey).
If you see the error “Permissions 0644 for ‘/home/username/.ssh/your_pem_file.pem:’ are too open,” it means that the permissions on your private key file (your_pem_file.pem) are too permissive. In other words, the file is readable by anyone on the system, which could potentially compromise the security of your private key.
To fix this error, you will need to change the permissions on your private key file so that it is only readable by you. To do this, you can use the chmod command to change the permissions on the file.
Here’s an example of how to use the chmod command to change the permissions on your private key file:
# chmod 600 /home/username/.ssh/your_pem_file.pem
This command will set the permissions on the file to 600, which means that the file is only readable and writable by the owner (you). This will ensure that the file is only accessible by you, and not by anyone else on the system.
You can try it now and then you are able to log in to an instance by SSH command.