#! /bin/bash
# install ssh key on remote systems.
if [ "$1" = "" ]; then
    cat <<EOF
Please give me a hostname
EOF
    exit 1
fi

if [ ! -f ~/.ssh/identity.pub ]; then
    echo "Please run mikilab-ssh-localinstall first" 
    exit 1
fi

echo "installing ssh v1 key on remote system" 

cat ~/.ssh/identity.pub | ssh "$1" "cat >> ~/.ssh/authorized_keys ; chmod 600 ~/.ssh/authorized_keys"

if [ -f ~/.ssh/id_dsa.pub ]; then 
    echo "installing ssh v2 DSA key on remote system"
    cat ~/.ssh/id_dsa.pub | ssh "$1" "cat >> ~/.ssh/authorized_keys2 ; chmod 600 ~/.ssh/authorized_keys2"
fi

