↑ ↓ select, Enter open, Esc close

Fix permissions of .ssh and authorized_keys

Caution: This command changes the system. Understand what it does before you run it.

user@server
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys

Sets the ~/.ssh directory to 700 and authorized_keys to 600. With the default setting StrictModes yes, sshd refuses keys if these files are writable by others. The journal then shows a message like Authentication refused: bad ownership or modes.

Note: The home directory itself must not be writable by group or others either. The command must run as the affected user so that ~ points to the right directory.

Also searched as

  • authentication refused bad ownership or modes
  • ssh key ignored permissions
  • correct permissions for .ssh folder

Related one-liners

All in SSH

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.