Setting SSH Key Permissions - Permission denied (publickey)
If you use ssh (Secure Shell) then you have likely encountered this error.
Permission denied (publickey)
If you haven’t generated a key use ssh-keygen to create a key for ssh sessions.
Linux
Usually, your key file will be located at ~/.ssh/id_rsa.pub on UNIX based systems
chmod 600 path/to/key/keyfile
Windows
Usually, your key file will be located at %USERPROFILE%.ssh\id_rsa.pub
Run this command to enable inheritance
icacls path/to/key/keyfile /inheritance:r
Run this command to grant read access to your user on the file
icacls file /grant:r yourusername:"(R)"