SSH Config Basics
concept~/.ssh/config is a named set of connection instructions—not a routing table for hostnames. Each block gives a nickname to a full set of connection details, so ssh myserver replaces a command line full of flags.
The basic structure:
Host nickname
HostName actual-server.com
User remote-username
Port 2222
IdentityFile ~/.ssh/specific_key
IdentitiesOnly yes
The fields:
Host—what you type:ssh nicknameHostName—real address (DNS or IP)User—remote username (defaults to your local username)Port—SSH port (defaults to 22)IdentityFile—which key to useIdentitiesOnly yes—only try the specified keys
The before/after is the whole sales pitch. Without config:
ssh -i ~/.ssh/id_work_yk -p 2222 [email protected]
With config: ssh work. Short memorable names, the correct key always used, port and username remembered—and git operations against configured hosts just work.