I try to be a good citizen and create unique ssh keys for each service I ssh into. I setup all sorts of fun config items and one of my favorites is host aliases. I have accumulated dozens of hosts in my config file and remembering the names of each can be problematic. I tend to open the config file a couple times a day to find a host. This morning I whipped up a quick command that will dump a list of all my hosts into the terminal with one command. No more opening the config file with an editor and scrolling through it. Hopefully this will be something you can enjoy also!
The command is:
grep -w -i "Host" ~/.ssh/config | sed 's/Host//'
It uses grep to search through the ssh config file and sed to clean up the output.
But wait! That is a lot to type and this was supposed to make life easier. Add this as a shell alias and simply type sshhosts to get the list!
alias sshhosts="grep -w -i "Host" ~/.ssh/config | sed 's/Host//'"