Stop Typing IP Addresses: Use SSH Config Aliases

· Rack Notes


An IP address is an implementation detail, not a memorable name. Once a homelab has more than a few machines, repeated commands such as ssh admin@192.0.2.31 become slow to type and easy to mistype.

The SSH client already has a small inventory system. Add entries to ~/.ssh/config on the workstation:

Host pve-a
    HostName 192.0.2.31
    User admin
    IdentityFile ~/.ssh/id_ed25519

Host backup
    HostName 192.0.2.42
    User backup-admin
    IdentityFile ~/.ssh/id_ed25519

Then connect with a name:

1ssh pve-a
2scp notes.txt backup:/srv/incoming/

The alias is local, so it works before internal DNS is ready and can include a different username, port, key, or jump host for each destination. Keep the file private because it documents the shape of the network:

1chmod 600 ~/.ssh/config

Use names that describe roles or stable nodes. Avoid aliases such as server1 that become meaningless six months later. If a machine's address changes, edit one line instead of changing shell history, scripts, and muscle memory.

SSH config is not a replacement for DNS or configuration management. It is the smallest useful layer between a human and a growing collection of machines—and one of the easiest homelab improvements to adopt in five minutes.

Aliases also compose well with other tools. Ansible inventory variables can refer to the same hostnames, Git can use an SSH alias for a self-hosted remote, and rsync accepts it without additional flags. Keep automation explicit when portability matters, but let interactive work benefit from the shorter name.

Before adding dozens of entries, test two. Run ssh -G pve-a to inspect the effective configuration without opening a session. It reveals which hostname, user, port, and identity SSH selected after processing all matching blocks.

last updated: