rubin110

Untitled

May 14th, 2010
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/bash
  2. if [ "`echo -n`" = "-n" ]; then
  3.   n=""; c="\c"
  4. else
  5.   n="-n"; c=""
  6. fi
  7.  
  8. echo $n "Host: $c"; read host
  9. if [ "$host" = "" ]; then
  10.   echo "Exiting: Host not specified"
  11.   exit 1
  12. fi
  13. echo $n "Username ("`whoami`"):$c"; read user
  14. if [ "$user" = "" ]; then
  15.   user=`whoami`
  16. fi
  17. DSA_FILE=~/.ssh/id_dsa.pub
  18. RSA_FILE=~/.ssh/id_rsa.pub
  19. if [ -f "$1" ]; then
  20.   KEYFILE=$1
  21. elif [ -f $DSA_FILE ]; then
  22.   KEYFILE=$DSA_FILE
  23. elif [ -f $RSA_FILE ]; then
  24.   KEYFILE=$RSA_FILE
  25. else
  26.   echo "Exiting: Public key not found"
  27.   exit 1
  28. fi
  29. PUBKEY=`cat $KEYFILE`
  30. 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