When using SSH connection, you may encounter the warning WARNING: UNPROTECTED PRIVATE KEY FILE!. This occurs because your private key file permissions are too loose. SSH requires private key files to have strict access restrictions, allowing only the owner to read and write.

WARNING: UNPROTECTED PRIVATE KEY FILE!
WARNING: UNPROTECTED PRIVATE KEY FILE!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'D:\\MyData\\xxxxxx.key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "D:\\MyData\\xxxxxx.key": bad permissions
xxxx@xx.xx.xx.xx: Permission denied (publickey).

Linux Solution

Modify the permissions of your private key file to ensure only you can read and write it:

chmod 600 ~/.ssh/your_private_key

Windows Solution

Right-click the private key file, open [Properties] > [Security] > [Advanced], change the file owner to your current user, [Disable inheritance], and remove permissions for other principals:

Change file ownership
Change file ownership
File permission details
File permission details