source: src-qt4/life-preserver/scripts/setup-ssh-keys.sh @ 0de3f5a

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 0de3f5a was 0de3f5a, checked in by Ken Moore <ken@…>, 8 months ago

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

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#!/bin/sh
2# Script for Life-Preserver which sets up password-less logins for ssh host
3###########################################################################
4
5SSHUSER=$1
6SSHHOST=$2
7SSHPORT=$3
8
9if [ -z "${SSHUSER}" -o -z "${SSHHOST}" ]
10then
11echo "ERROR: Usage setup-ssh-keys.sh <user> <host>"
12  exit 150
13fi
14
15cd /root
16
17echo "Preparing to setup SSH key authorization..."
18echo "When prompted, enter your password for ${SSHUSER}@${SSHHOST}"
19
20if [ ! -e ".ssh/id_rsa.pub" ]
21then
22mkdir .ssh >/dev/null 2>/dev/null
23  ssh-keygen -q -t rsa -N '' -f .ssh/id_rsa
24  sleep 1
25fi
26
27if [ ! -e ".ssh/id_rsa.pub" ]
28then
29echo "ERROR: Failed creating .ssh/id_rsa.pub"
30  sleep 5
31  exit 150
32fi
33
34# Get the .pub key
35PUBKEY="`cat .ssh/id_rsa.pub`"
36
37echo $PUBKEY | ssh -p $SSHPORT $SSHUSER@$SSHHOST 'mkdir .ssh ; chmod 700 .ssh ; tee -a .ssh/authorized_keys ; chmod 644 .ssh/authorized_keys'
38
39echo $PUBKEY | ssh -p $SSHPORT $SSHUSER@$SSHHOST 'mkdir .ssh ; chmod 700 .ssh ; tee -a .ssh/authorized_keys2 ; chmod 644 .ssh/authorized_keys2'
40
41
42if [ "$?" != "0" ]
43then
44touch /tmp/.failedPreserver-${SSHUSER}
45fi
Note: See TracBrowser for help on using the repository browser.