Interview Prep/Linux/SSH, sudo and authentication

Permissions on `~/.ssh` are correct, but you still get `Permission denied (publickey)` and the server log says `Authentication refused: bad ownership or modes for directory /home/deploy`.

IntermediateTroubleshootingSSH, sudo and authentication
Answer

Likely causes → The home directory itself is group- or world-writable (StrictModes yes checks every path component).

Diagnose →

sudo journalctl -u sshd | grep -i 'bad ownership'
namei -l /home/deploy/.ssh/authorized_keys

Fix → sudo chmod 755 /home/deploy (or 750), owned by the user.

Prevent → Don't chmod 777 home directories to "fix" sharing; use groups.

All Linux questions Roadmap: Linux

More on SSH, sudo and authentication