Today I learned: SSH permissions on Linux and ssh-agent

Before troubleshooting SSH issues, make sure your permissions are right — wrong permissions are a common silent culprit.

The .ssh directory should be 700 (rwx------) — only your user can enter, read, or modify it.

Both authorized_keys and private keys should be 600 (rw-------) — only your user can read and write them.

Public keys should be 644 (rw-r--r--) — everyone can read, but only your user can modify.

To start the ssh-agent:

eval $(ssh-agent -s)

To add a key to the agent use:

ssh-add path/to/key.

Afterwards please confirm that the key is loaded:

ssh-add -L

This should list the public keys currently held by the agent.

Leave a comment