Skip to content

Instantly share code, notes, and snippets.

@smichaelsen
Last active December 29, 2015 12:59
Show Gist options
  • Save smichaelsen/7674633 to your computer and use it in GitHub Desktop.
Save smichaelsen/7674633 to your computer and use it in GitHub Desktop.
List configured ssh hosts
# Lists your configured SSH hosts
#
# example .ssh/config:
#
# +----------------------------------+
# |# Intranet |
# |Host Bilbo |
# | HostName bilbo.intranet |
# | User MyUser |
# |Host Frodo |
# | HostName frodo.intranet |
# | User MyUser |
# | |
# |# Clients |
# |Host Client1 |
# | HostName client1.example.com |
# | User OurUser |
# | Port 8022 |
# |Host Client2 |
# | Hostname client2.example.com |
# | |
# |# Our Servers |
# |Host webserver |
# | Hostname ourdomain.com |
# | User OurUser |
# |Host fileserver |
# | Hostname fileserver.example.com|
# +----------------------------------+
#
#
# example output:
#
# # Intranet
# Bilbo
# Frodo
# # Clients
# Client1
# Client2
# # Our Servers
# webserver
# fileserver
#
cat ~/.ssh/config | grep "Host \|# " | sed 's/Host //g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment