user@homelab:~/docs$ cat ssh.md
SSH
Key-only SSH from the Mac and iPad, with password and root login disabled
# contents
Overview
| Goal | SSH with per-device keys only |
| Clients | Mac (Terminal), iPad (Termius) |
| Result | ssh homelab works at home and away (via Tailscale); passwords and root login disabled |
Each device has its own ED25519 key. The private key never leaves the device; the server holds only public keys in ~/.ssh/authorized_keys. A lost device is revoked by deleting one line.
1. Mac
ssh-keygen -t ed25519 -C "mac->homelab"Use a passphrase; macOS stores it in the Keychain.
# ~/.ssh/config
Host homelab
HostName homelab.<tailnet>.ts.net
User <user>
IdentityFile ~/.ssh/id_ed25519
AddKeysToAgent yes
UseKeychain yesssh-copy-id homelabssh-copy-id uses the account password one last time, appends the public key and fixes permissions.
2. iPad (Termius)
- Keychain → Generate Key, type ED25519, name
ipad. - Append the public key on the server, one key per line:
nano ~/.ssh/authorized_keys- Hosts → New Host: hostname
homelab.<tailnet>.ts.net, port22, user<user>, keyipad, no password.
3. Disable password login
# /etc/ssh/sshd_config.d/00-hardening.conf
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin nosudo sshd -t && sudo systemctl restart sshFiles in sshd_config.d/ are read alphabetically and the first value wins; the 00- prefix takes precedence over files shipped by the installer (e.g. 50-cloud-init.conf).
Verify
sudo sshd -T | grep -E 'passwordauthentication|kbdinteractive|permitrootlogin'ssh homelab # must succeed
ssh -o PubkeyAuthentication=no homelab # must fail: Permission denied (publickey)Notes
- Authentication failures are explained in the server log:
sudo journalctl -u ssh -n 20 --no-pager. - Handshake finished followed by a failure in a client means the network path works and authentication did not.