Stop typing long ssh commands
2024-11-22
If you find yourself typing ssh -p 2222 -i ~/.ssh/some_key user@host.example.com more than a couple of times, put it in ~/.ssh/config:
Host nas
HostName 192.168.1.50
User admin
Port 2222
IdentityFile ~/.ssh/some_key
Now ssh nas does the same thing. Same goes for scp nas:file . and the various tools that internally use ssh.
Wildcards work too. Host *.work can apply a set of defaults to anything ending in .work, and a final Host * block at the bottom sets fallback defaults like ServerAliveInterval 60.