Skip to content

Instantly share code, notes, and snippets.

@david-sanabria
Created January 12, 2017 02:04
Show Gist options
  • Save david-sanabria/f22237025ba9684cc8af0a0d39435d4b to your computer and use it in GitHub Desktop.
Save david-sanabria/f22237025ba9684cc8af0a0d39435d4b to your computer and use it in GitHub Desktop.
This gist provides a bash command that looks at your ssh configuration file and uses it to give you a list of ssh hosts that you have configured
if [ -f ~/.ssh/config ]; then
#Print simple list
grep ~/.ssh/config -e 'Host ' | awk '{print $2}'
#provide list in Select form to allow quickly connecting to the target
select TGT in $(grep ~/.ssh/config -e 'Host ' | awk '{print $2}');
do
ssh $TGT
done;
else
echo "You need to add some configurations to your SSH Config file before this does anything useful"
echo " Hint: type "man ssh_config" for more information"
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment