SSH (ssh.service)

Install:

sudo apt update
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo status ssh
SettingValueWhy
Port<SSH_PORT>Moves SSH off port 22, which cuts down automated scans
PermitRootLoginnoRoot can’t log in directly
PubkeyAuthenticationyesKey-based login
PasswordAuthenticationnoKeys only, no passwords
MaxAuthTries6Default

Config: /etc/ssh/sshd_config or a drop-in in /etc/ssh/sshd_config.d/*.conf

Connect

ssh -p <SSH_PORT> <USER>@<LAN_IP>     # on the LAN
ssh -p <SSH_PORT> <USER>@<HOSTNAME>   # anywhere, via Tailscale MagicDNS

Check effective settings

sudo sshd -T | grep -Ei '^(port|permitrootlogin|passwordauthentication|pubkeyauthentication|maxauthtries)'

Apply changes safely

Keep your current session open while testing a new one:

sudo sshd -t && sudo systemctl restart ssh

Related: 04 - Firewall (UFW) · 05 - Fail2ban · Back: 00 - Overview