Interview Prep/Linux/SSH, sudo and authentication

SFTP users in a chroot get disconnected immediately; the server log says `fatal: bad ownership or modes for chroot directory "/sftp/partner1"`.

AdvancedTroubleshootingSSH, sudo and authentication
Answer

Likely causes → The chroot directory and every parent must be owned by root and not writable by group/others.

Diagnose →

namei -l /sftp/partner1
sudo journalctl -u sshd | grep -i chroot

Fix →

sudo chown root:root /sftp /sftp/partner1
sudo chmod 755 /sftp /sftp/partner1
sudo mkdir -p /sftp/partner1/upload && sudo chown partner1: /sftp/partner1/upload

Prevent → Template the chroot creation; users write only to subdirectories.

All Linux questions Roadmap: Linux

More on SSH, sudo and authentication