ssh: Remember each host's settings

Published On: Thursday, February 25th 2016
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. ~/.ssh/config 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.key

Host 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:
ssh prod
Happy Computing!

Tag Cloud

Copyright © 2024 Barry Gilbert.