unix / ssh

I reach my VMs and Git hosts over SSH. A little ~/.ssh/config turns long commands into short aliases.

Keys

I use one Ed25519 key pair:

ssh-keygen -t ed25519 -C "dan@example.com"

The public half, ~/.ssh/id_ed25519.pub, goes on the server in ~/.ssh/authorized_keys or the provider's UI. The private half stays on my laptop.

Host aliases

Without config, reaching a VM means repeating its IP, user, and key:

ssh -i ~/.ssh/id_ed25519 croaky@203.0.113.10

A Host block in ~/.ssh/config shortens that to ssh cibot-farmer:

Host cibot-farmer
  HostName 203.0.113.10
  User croaky
  IdentityFile ~/.ssh/id_ed25519

scp and rsync understand the alias too:

scp ./cibot cibot-farmer:/tmp/cibot

Splitting config

My dotfiles are public, so ~/.ssh/config holds only safe defaults and machine-specific hosts live in separate files, pulled in with Include:

# ~/.ssh/config
Include ~/.ssh/config.private*

Any file matching ~/.ssh/config.private* is read, so I drop a ~/.ssh/config.private_cibot with the VM aliases and keep it out of the public repo. SSH ignores config files that are group- or world-readable, so chmod 600 them.

I automate the rest of my machine setup in cmd / laptop.

← All articles