Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 19 lines (14 sloc) 665 Bytes
#/bin/sh
# install key on remote server for no-password login
SERVER="$1"
[ -z "$SERVER" ] && echo -n "Enter server or user@server: " && read SERVER
USER="${SERVER%@*}"
[ "$USER" = "$SERVER" ] && USER="root"
SERVER="${SERVER#*@}"
[ -z "$USER" ] && USER=`whoami`
# generate our local key
[ ! -d ~/.ssh ] && mkdir -p ~/.ssh
[ ! -f ~/.ssh/id_dsa.pub ] && ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
IAM="`whoami`@$HOSTNAME"
echo "Installing ssh key for $IAM on $USER@$SERVER"
ssh $USER@$SERVER "mkdir -p ~/.ssh;[ -f ~/.ssh/authorized_keys ] && sed -i "/$IAM/d" ~/.ssh/authorized_keys;cat >>~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys" <~/.ssh/id_dsa.pub
Something went wrong with that request. Please try again.