brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: chmod 700 ~/.ssh fixes SSH keys that the server quietly ignores

Network and access
~/tips/tip-ssh-folder-permissions

chmod 700 ~/.ssh

Correct the permissions sshd checks before it trusts your authorized_keys file.

You copied the key, the line is in authorized_keys, and the server still asks for a password. Before anything else, I’d check the permissions, because sshd skips files it considers unsafe.

On the server, as the user you log in as:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod go-w ~

This is the StrictModes setting in sshd_config, on by default. sshd checks ownership and modes of your home folder, ~/.ssh and the key file, and if another user could write to them, it ignores the key. Your home folder being group writable is enough to trigger it.

Ownership matters as well. If you created the files with sudo, they might belong to root:

chown -R "$USER": ~/.ssh

On your own machine the same idea applies to private keys. ssh refuses a private key that other users can read, with a loud UNPROTECTED PRIVATE KEY FILE warning, and chmod 600 ~/.ssh/id_ed25519 fixes that.

The server log tells you if this is the problem. Look for a line about bad ownership or modes in journalctl -u ssh (or sshd, depending on the distribution). Please do not set StrictModes to no to make it go away; fixing the permissions takes ten seconds.

Further reading: sshd_config man page, sshd man page, FILES

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link