Create a handy SSH Dialog from your .ssh/config File


If you want to create a simple SSH Server Login Menu for your shell with all your configured Servers in your .ssh/config file, you can use this little script:

#!/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 "Please choose a Server:" 30 45 10 "${ar[@]}" 2> $tempfile retval=$? choice=`cat $tempfile` case $retval in 0) clear echo "connecting $choice" echo "" ssh $choice server;; 1) clear;; 255) echo "Bye!";; esac

This script will read your .ssh/config file and create a dialog menu with all the servers you have configured. If you select one of them, it will connect to that server via ssh.

The script uses the dialog utility which is part of most Linux distributions. You can install it on macOS using brew:

brew install dialog

or on Ubuntu/Debian:

sudo apt install dialog