DEV Community


Posted on

Show the hosts configured in your SSH config file

Recently I had to connect via SSH to several hosts. It's hard for me to remember their full domain, not to mention all the options required (identity file, port, etc.) to connect.

The SSH config file (~/.ssh/config) is the best place to store this information but then again I have to remember all the name I used for such hosts..

No memory

To make my life even more comfortable, I created this little Ruby script that shows a sorted list of the hosts present in the SSH config file:

Behold! 🧙🏼‍♂️


cat ~/.ssh/config | ruby -e "puts {|l| l.match(/^Host\ (.*)$/)} {|r| r[1]}.sort"

Discussion (0)