szaydel
8/18/2011 - 1:25 PM

gistfile1.sh

setup_ssh_key ()
{
## Function used to call ssh-copy-id script to copy my primary ssh-pub-key over
## to any new system being setup

## If length of arguments is less than 2
if [ ${#@} -lt 2 ]; then
	printf "%s\n" "Not enough arguments, please supply username and hostname." \
	"Expected: $0 <username> <hostname>"
	return 1
fi

	local username=$1
	local mypubkey="~/.ssh/<your_ssh_pubkey>.pub"
	local remote_host=$2
	local ssh_cmd="/usr/bin/ssh-copy-id -i"

	${ssh_cmd} ${mypubkey} ${username}@${remote_host}
}