~/.ssh/config — your remote address book
Without config, every ssh command needs the full host, user, port, key path. ~/.ssh/config turns ssh -i ~/.ssh/work_id -p 2222 alice@server.example.com into ssh work. Same for scp, rsync, and any tool that uses ssh under the hood.
The shape
Host work
HostName server.example.com
User alice
Port 2222
IdentityFile ~/.ssh/work_id_ed25519
IdentitiesOnly yes
Host *.internal
User root
ProxyJump bastion.internalIndent the directives. Patterns (*.internal, 10.0.*) match by host alias. Order matters — earlier blocks win on conflict.
Common directives
IdentityFile ~/.ssh/foo— which key to use.IdentitiesOnly yes— try only that key (avoids ssh-agent spamming all your keys until the server locks you out).ProxyJump bastion— go through a jump host.ForwardAgent yes— forward your local agent (use carefully).LocalForward 5900 localhost:5900— auto-tunnel on connect.ControlMaster auto,ControlPath ~/.ssh/cm-%r@%h:%p— share a single connection between commands. Speeds up rsync loops massively.
Permissions matter
~/.ssh must be 700, files inside 600. Loose permissions make ssh refuse to use the key ("Permissions are too open"). One chmod 700 ~/.ssh; chmod 600 ~/.ssh/* after cloning a dotfiles repo saves an hour of debugging.
Test fast
ssh -T host tries to authenticate without opening a shell. ssh -v host shows every step the client takes. Use these for debugging.