Fixing SSH files and folder permissions

SSH Permissions

When using SSH key pairs to authenticate to a distant server, these keys are stored onto your client, typically under ~/.ssh folder. Unless you’re using Windows. In this case there is nothing I can do for you.

Using Lynis to audit a server, I asked myself what could be the best practices in terms of permission for ~/.ssh folder and its content.

Here are values I recommend.

For ~/.ssh folder:

For public key:

For private key:

Further readings: