You will get the following error if you try to log in to an SSH server using a private key that has a very open permission.
debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /Users/shakir/.ssh/simplified-guide.pem @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0755 for '/Users/shakir/.ssh/simplified-guide.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 "/Users/shakir/.ssh/simplified-guide.pem": bad permissions
The key will have the correct permission when created using ssh-keygen, but will change when being copied using tools that are not set to preserve the permission, which normally will use the permission as defined in the system's umask value.
To use the problematic private key, you will need to first change the permission of the key to a minimally accepted value.
Related: How to generate SSH key pairs
Steps to change SSH private key permission in Linux:
- Get the location of private SSH key file.
- Launch terminal.
- Get the current permission of the private key(optional).
$ ls -l .ssh/simplified-guide.pem -rwxr-xr-x@ 1 shakir staff 1700 May 12 2021 .ssh/simplified-guide.pem
- Change the permission of the SSH private key to the acceptable level.
$ chmod 600 .ssh/simplified-guide.pem
The file must be owned by the user where the user has read and execute access, and is set to allow no access at all to user's group or other users.
- Try to connect again using the public key authentication method.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.