How do you restrict what a specific SSH key can do?
AdvancedProductionSSH & Access Hardening
Answer
Prefix options in authorized_keys:
from="10.0.0.0/16",command="/usr/local/bin/backup-receive",restrict ssh-ed25519 AAAA... backup@ci
restrict disables port, agent and X11 forwarding and PTY allocation; command= forces a single command regardless of what the client asks; from= limits source addresses. This is how we give CI or backup systems narrowly scoped access.
More on SSH & Access Hardening
What are the first sshd_config changes you make on a new production server?BeginnerWhy use a drop-in file in /etc/ssh/sshd_config.d/ instead of editing sshd_config?IntermediateWhy disable SSH password authentication entirely?BeginnerShould you change the SSH port from 22?IntermediateWhat are SSH certificates and why do large fleets use them?AdvancedHow do you apply different sshd rules for different users or networks?Intermediate