Created
June 23, 2020 11:01
-
-
Save simonjenny/3132015cb3ce88752abec0daeaee4a82 to your computer and use it in GitHub Desktop.
Easy SSH Dialog based on your SSH Config
This file contains 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
#!/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