Skip to content
Mementropy
RecipesHomelab recipesReference

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.

By Ryan Hammang

Letting one workstation log in to new hosts, and to Gitea over SSH, with keys only.

  • 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)
  1. 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:
Terminal window
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'
  1. 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
  1. Accept the host key once:
Terminal window
ssh -o StrictHostKeyChecking=accept-new host-a true
  1. 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 yes

Then switch the repo remote to ssh://git@gitea.example.home.arpa:2222/<owner>/<repo>.git.

  • ssh -o BatchMode=yes host-a hostname prints the hostname with no prompt.
  • ssh -T git@gitea.example.home.arpa -p 2222 greets you by user name.
  • A soft-wrapped paste split chmod 600 from 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 yes and IdentityAgent none fixed it.
  • Gitea’s SSH port answered nc, but no keys were registered. Test a real git push, not just the port.