When you start using ssh to connect to other linux-based computers, you’re probably only going to a handful of machines. Easy enough to remember the username and hostname, but this won’t do when you’re working on 5 or more servers, especially if some offer ssh on a non-default port.
In this file, you can set all the options for each host, including the username, host or ip, port, even which key to use. Here’s an example:
#Contents of $HOME/.ssh/config Host dev HostName 192.168.0.1 User dev-deploy Port 2222 IdentityFile ~/.ssh/id_rsa.deploy.keyHost prod HostName www.example.com User prod555deploy Port 5899 Host www.example.com User admin123 Port 5899
It’s that easy! To use this config information, simply ssh: