#!/bin/sh BASEDIR=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd) SSH_KEY=${BASEDIR}/$(ls ${BASEDIR} | egrep '.pem$' | head -n 1) if [ $# -lt 1 ]; then >&2 echo "Usage: $0 " exit 1 fi host=$1 user=$(whoami) for h in $(cat ${BASEDIR}/hosts | grep -v "^#" | egrep "\\s+${host}(\\s+.*)*$" | awk '{print $1}') do host=${h} break done ssh -i ${SSH_KEY} ${host}