Setting SSH Key Permissions - Permission denied (publickey)
If you use ssh (Secure Shell), you likely encounter this error.
Permission denied (publickey)
If you haven’t generated a key, use ssh-keygen to create a key for ssh sessions.
Usually, you’ll find your key at ~/.ssh/id_rsa.pub on UNIX based systems
chmod 600 path/to/key/keyfile
Usually, you’ll find your key 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)"