Skip to content

Instantly share code, notes, and snippets.

@seikai
Last active December 11, 2015 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seikai/4663499 to your computer and use it in GitHub Desktop.
Save seikai/4663499 to your computer and use it in GitHub Desktop.
ssh config からHostを選ぶ
#!/bin/bash
SSH_CONFIG=/Users/hoge/.ssh/config
if [[ -e $SSH_CONFIG ]]; then
servers=$(cat $SSH_CONFIG | grep -e "^Host " | awk '{ print $2 }')
servers+=("QUIT")
PS3="select server alias to connect"
select server in ${servers[@]}; do
if [[ -z $server ]]; then
echo "invalid select!"
continue;
fi
if [[ $server == "QUIT" ]]; then
echo "exit..."
exit 0
fi
echo "connect to $server ..."
ssh "$server"
break
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment