Created
January 12, 2017 02:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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