Setting up SSH keys from a workstation to new homelab hosts
Add a workstation key to new hosts, pin host keys, and keep pasted lines short.
What it’s for
Section titled “What it’s for”Letting one workstation log in to new hosts, and to Gitea over SSH, with keys only.
What you need
Section titled “What you need”- A workstation key pair, for example
~/.ssh/id_ed25519_ws - One existing way in to each host (console, or another machine that can already log in)
- From a machine that can already log in, append the workstation’s public key. Keep each line short so a terminal wrap can’t split it:
PUB="$(cat id_ed25519_ws.pub)"ssh admin@host-a 'mkdir -p -m 700 ~/.ssh'ssh admin@host-a "echo '$PUB' >> ~/.ssh/authorized_keys"ssh admin@host-a 'chmod 600 ~/.ssh/authorized_keys'- On the workstation, add a host block. Pin the key file and stop the SSH agent from offering other keys first:
Host host-a User admin IdentityFile ~/.ssh/id_ed25519_ws IdentitiesOnly yes IdentityAgent none- Accept the host key once:
ssh -o StrictHostKeyChecking=accept-new host-a true- For Gitea on SSH port 2222, register the public key with
POST /api/v1/user/keys(or in the web UI) and add:
Host gitea.example.home.arpa User git Port 2222 IdentityFile ~/.ssh/id_ed25519_ws IdentitiesOnly yesThen switch the repo remote to ssh://git@gitea.example.home.arpa:2222/<owner>/<repo>.git.
Check it worked
Section titled “Check it worked”ssh -o BatchMode=yes host-a hostnameprints the hostname with no prompt.ssh -T git@gitea.example.home.arpa -p 2222greets you by user name.
Traps seen
Section titled “Traps seen”- A soft-wrapped paste split
chmod 600from its file argument. Earlier commands in the&&chain had already run. - With a password-manager SSH agent active, OpenSSH offered agent keys first and failed with
Permission denied (publickey).IdentitiesOnly yesandIdentityAgent nonefixed it. - Gitea’s SSH port answered
nc, but no keys were registered. Test a realgit push, not just the port.
Where this came from
Section titled “Where this came from”- A terminal line wrap split a chmod command (2026-10-17)
- Reviewing phases 1 to 3 (2026-10-20)