Permalink
Browse files

Re-add the scripts/setup-ssh-keys.sh file from the old life-preserver…

… into the new one.
  • Loading branch information...
1 parent 603823a commit 0de3f5a078ce9ecb1842cec6b3d3c130dc302a8f Ken Moore committed Aug 20, 2013
Showing with 45 additions and 0 deletions.
  1. +45 −0 src-qt4/life-preserver/scripts/setup-ssh-keys.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Script for Life-Preserver which sets up password-less logins for ssh host
+###########################################################################
+
+SSHUSER=$1
+SSHHOST=$2
+SSHPORT=$3
+
+if [ -z "${SSHUSER}" -o -z "${SSHHOST}" ]
+then
+echo "ERROR: Usage setup-ssh-keys.sh <user> <host>"
+ exit 150
+fi
+
+cd /root
+
+echo "Preparing to setup SSH key authorization..."
+echo "When prompted, enter your password for ${SSHUSER}@${SSHHOST}"
+
+if [ ! -e ".ssh/id_rsa.pub" ]
+then
+mkdir .ssh >/dev/null 2>/dev/null
+ ssh-keygen -q -t rsa -N '' -f .ssh/id_rsa
+ sleep 1
+fi
+
+if [ ! -e ".ssh/id_rsa.pub" ]
+then
+echo "ERROR: Failed creating .ssh/id_rsa.pub"
+ sleep 5
+ exit 150
+fi
+
+# Get the .pub key
+PUBKEY="`cat .ssh/id_rsa.pub`"
+
+echo $PUBKEY | ssh -p $SSHPORT $SSHUSER@$SSHHOST 'mkdir .ssh ; chmod 700 .ssh ; tee -a .ssh/authorized_keys ; chmod 644 .ssh/authorized_keys'
+
+echo $PUBKEY | ssh -p $SSHPORT $SSHUSER@$SSHHOST 'mkdir .ssh ; chmod 700 .ssh ; tee -a .ssh/authorized_keys2 ; chmod 644 .ssh/authorized_keys2'
+
+
+if [ "$?" != "0" ]
+then
+touch /tmp/.failedPreserver-${SSHUSER}
+fi

0 comments on commit 0de3f5a

Please sign in to comment.