Shared server guidance · Question & answer

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.

IntermediateWindows 11 with Microsoft OpenSSH Client; Windows PowerShell 5.1 or PowerShell 7 as labelledLinux VPS and dedicated servers where a remote Linux command is shown
Go to the answer

Instructions

1. Inspect the exact account paths

Run these checks inside the affected account’s session or through an authorised console.

Remote Linux shell
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.

Remote Linux shell
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.