#!/usr/bin/env bash NORMAL=$(tput sgr0) GREEN=$(tput setaf 2; tput bold) YELLOW=$(tput setaf 3) RED=$(tput setaf 1) function red() { echo -e "$RED$*$NORMAL"; } function green() { echo -e "$GREEN$*$NORMAL"; } function yellow() { echo -e "$YELLOW$*$NORMAL"; } if [ ! $# == 2 ]; then echo "Usage: $0 " exit 1; fi USER=$1 HOST=$2 IP=`dig +short $HOST` if [ -z "$IP" ]; then IP=$HOST fi grep "Host $HOST" ~/.ssh/config 2>&1 > /dev/null if [ 0 -eq $? ]; then echo $HOST is already in .ssh/config else echo Adding server to .ssh/config... cat >> ~/.ssh/config <