Interview Prep/Linux/SSH & Access Hardening

How do you apply different sshd rules for different users or networks?

IntermediateProductionSSH & Access Hardening
Answer

Use Match blocks at the end of the config:

Match Group sftp-only
    ChrootDirectory /srv/sftp/%u
    ForceCommand internal-sftp
    AllowTcpForwarding no

Match Address 10.0.0.0/8
    PasswordAuthentication no

The chroot directory must be owned by root and not group/other-writable. Test a user's effective settings with sudo sshd -T -C user=bob,host=x,addr=10.1.2.3.

All Linux questions Roadmap: Linux

More on SSH & Access Hardening