Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ "`echo -n`" = "-n" ]; then
- n=""; c="\c"
- else
- n="-n"; c=""
- fi
- echo $n "Host: $c"; read host
- if [ "$host" = "" ]; then
- echo "Exiting: Host not specified"
- exit 1
- fi
- echo $n "Username ("`whoami`"):$c"; read user
- if [ "$user" = "" ]; then
- user=`whoami`
- fi
- DSA_FILE=~/.ssh/id_dsa.pub
- RSA_FILE=~/.ssh/id_rsa.pub
- if [ -f "$1" ]; then
- KEYFILE=$1
- elif [ -f $DSA_FILE ]; then
- KEYFILE=$DSA_FILE
- elif [ -f $RSA_FILE ]; then
- KEYFILE=$RSA_FILE
- else
- echo "Exiting: Public key not found"
- exit 1
- fi
- PUBKEY=`cat $KEYFILE`
- ssh $user@$host "mkdir -p ~/.ssh;echo \"$PUBKEY\" >> ~/.ssh/authorized_keys;chmod go-w ~/.ssh;chmod go-w ~/.ssh/authorized_keys"
Add Comment
Please, Sign In to add comment