What permissions should my Linux SSH key files have?
For a normal user-managed setup, the .ssh directory should be accessible only to its owner and authorized_keys should be writable only by that owner. SSH also considers ownership and the surrounding directory path. Fix the affected account only.
Instructions
1. Inspect the exact account paths
Run these checks inside the affected account’s session or through an authorised console.
id
ls -ld "$HOME" "$HOME/.ssh"
ls -l "$HOME/.ssh/authorized_keys"Confirm the owner is the intended account and that other users cannot modify the key path.
2. Apply narrow permissions if the files are user-managed
Do not apply these modes to centrally managed or shared special-purpose paths without checking their design.
chmod 700 "$HOME/.ssh"
chmod 600 "$HOME/.ssh/authorized_keys"These commands affect only the named directory and file; they do not recursively change the home directory.
3. Check ownership or policy failures separately
If files were created by another account, correct their ownership through the responsible administrator. Keep the existing session open and verify a second login. A permissions change cannot fix an incorrect public key or disabled account.
Check the result
- The .ssh directory and authorised-key file belong to the intended account.
- A new key-based session succeeds without unsafe-permission errors.
Troubleshooting
- Permission denied prevents chmod
- You may not own the files. Confirm the target identity before using administrative privileges.
- Permissions look correct but login fails
- Inspect the SSH log and active authorised-key policy, including any mandatory access-control restrictions.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
