Set up ssh host aliases in ~/.ssh/config
Turn ssh deploy@203.0.113.10 -p 2222 into just ssh web.
Add a Host block to ~/.ssh/config (Host web / HostName … / User … / Port …), then connect with ssh web.
01Command
Command
$ nano ~/.ssh/config && ssh web # after adding: Host web / HostName 203.0.113.10 / User deploy / Port 222202What it does
~/.ssh/config is read by the ssh client on every connection. Each block starts with Host nickname and sets HostName, User, Port, IdentityFile, and more; options also apply to scp, rsync, and git (git@web:repo). Wildcards like Host * set defaults for everything. chmod 600 ~/.ssh/config keeps ssh from complaining about permissions.
03Risk
!Warning: A mistake in this file can lock you out of servers: options match the FIRST matching Host block, so put specific hosts above wildcard blocks. Keep a copy of the file before rewriting it, and test with ssh -G web to see the resolved settings.
04Undo
Undo
$ Remove the Host block from ~/.ssh/config to delete the alias05Sources
- ssh_config(5) — OpenSSH client configuration fileEvidence: The per-user ~/.ssh/config file defines Host entries whose options (HostName, User, Port, IdentityFile) apply when the host alias is used on the ssh command line.
Last verified: 2026-09-18 · Category: Developer