Permissions are too open

Permissions are too open

Permissions are too open

If you SSH to a Linux machine and encounter the following error:

lyle@lyle-laptop:~/Downloads$ ssh -i key-test.pem lyle@10.0.0.6
Permissions 0640 for 'key-test.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored.
lyle@lyle-laptop:~/Downloads$ ll *.pem
-rw-r----- 1 lyle lyle 1696 Jan 12 14:06 key-test.pem
-rw------- 1 lyle lyle 1771 Jan 23 10:09 key-prod.pem

Now notice that the permissions for key-test.pem is 640 and the permissions for key-prod.pem is 600

If I was to SSH to a certain box using the key-test.pem it would give me the error above in the first line of this post. If I was to use the key-prod.pem and it is a valid key on that system then it would login without any problems.

To solve this we change the permission of the key file.

lyle@lyle-laptop:~/Downloads$ chmod 600 key-test.pem

Check the permissions

lyle@lyle-laptop:~/Downloads$ ll *.pem
-rw------- 1 lyle lyle 1696 Jan 12 14:06 key-test.pem
-rw------- 1 lyle lyle 1771 Jan 23 10:09 key-prod.pem

Now you would be able to SSH without any problem.

Just for reference in case you need. A little handy table.

7 4+2+1 (read/write/execute)
6 4+2 (read/write)
5 4+1 (read/execute)
4 4 (read)
3 2+1 (write/execute)
2 2 (write)
1 1 (execute)

Leave a Reply

Your email address will not be published. Required fields are marked *