Skip to content

Instantly share code, notes, and snippets.

@simonjenny
Created June 23, 2020 11:01
Show Gist options
  • Save simonjenny/3132015cb3ce88752abec0daeaee4a82 to your computer and use it in GitHub Desktop.
Save simonjenny/3132015cb3ce88752abec0daeaee4a82 to your computer and use it in GitHub Desktop.
Easy SSH Dialog based on your SSH Config
#!/bin/bash
DIALOG=${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
ar=()
for i in `cat ~/.ssh/config |grep -w Host| sed -e "s/Host //g" | grep -Ei '[a-z]'`
do
ar+=($i "")
done
$DIALOG --title "SSH Servers" --menu "Bitte wähle ein Server:" 0 0 10 "${ar[@]}" 2> $tempfile
retval=$?
choice=`cat $tempfile`
case $retval in
0)
clear
echo "Verbinde mit $choice"
echo ""
ssh $choice
server;;
1)
clear;;
255)
echo "ESC pressed.";;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment