Interview Prep/Linux/SSH, sudo and authentication

Key auth fails only on RHEL with SELinux enforcing; the server logs show nothing unusual about modes.

IntermediateTroubleshootingSSH, sudo and authentication
Answer

Likely causes → authorized_keys has the wrong SELinux context (copied or created in an unusual way, or the home directory is in a non-standard path like /data/home).

Diagnose →

ls -Z /home/deploy/.ssh/authorized_keys      # expect ssh_home_t
sudo ausearch -m AVC -c sshd -ts recent

Fix → sudo restorecon -Rv /home/deploy/.ssh. For a custom home root: semanage fcontext -a -e /home /data/home && restorecon -Rv /data/home.

Prevent → Use standard home locations or register equivalence rules.

All Linux questions Roadmap: Linux

More on SSH, sudo and authentication