Author: pwesolek
Date: Wed Dec 3 12:21:00 2008
New Revision: 85
Modified:
trunk/distcomp/scripts/rshknowhosts.sh
trunk/distcomp/scripts/rshlst.sh
trunk/distcomp/scripts/rshpar.sh
trunk/distcomp/scripts/rshseq.sh
Log:
Added option to specify SSH keyring to all commands (--ssh). The reason is that
sometimes you may want to be sure about hosts identifyi, e.g. when knocking to a
*different* SSH, running on Cygwin (dual boot labs). In such case, --ssh option
let you specify read-only known_hosts keyring (with exception of
rshknowhosts.sh, which is used to build such a keyring).
Modified: trunk/distcomp/scripts/rshknowhosts.sh
==============================================================================
--- trunk/distcomp/scripts/rshknowhosts.sh (original)
+++ trunk/distcomp/scripts/rshknowhosts.sh Wed Dec 3 12:21:00 2008
@@ -2,10 +2,18 @@
if [ $# -lt 1 ]; then
echo "Feeds SSH's known_hosts with a list of hosts. Usage:"
- echo "$0 hosts_file [username]"
+ echo "$0 [ --ssh known_hosts ] hosts_file [username]"
exit 1
fi
+if [ "$1" == "--ssh" ]; then
+ SSH_KNOWN_HOSTS_OPTS="-o UserKnownHostsFile=$2"
+ shift
+ shift
+else
+ SSH_KNOWN_HOSTS_OPTS=''
+fi
+
HOSTS=$1
shift
@@ -16,7 +24,7 @@
fi
# Don't wait too long for inaccessible hosts.
-SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes -o StrictHostKeyChecking=no"
+SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes -o StrictHostKeyChecking=no
$SSH_KNOWN_HOSTS_OPTS"
TMP=`mktemp -t -d`
sed -e 's/#.*//' -e '/^[ \t]*$/d' $HOSTS > $TMP/hosts
Modified: trunk/distcomp/scripts/rshlst.sh
==============================================================================
--- trunk/distcomp/scripts/rshlst.sh (original)
+++ trunk/distcomp/scripts/rshlst.sh Wed Dec 3 12:21:00 2008
@@ -2,10 +2,18 @@
if [ $# -lt 1 ]; then
echo "Lists SSH-accessible hosts. Usage:"
- echo "$0 hosts_file [username]"
+ echo "$0 [ --ssh known_hosts ] hosts_file [username]"
exit 1
fi
+if [ "$1" == "--ssh" ]; then
+ SSH_KNOWN_HOSTS_OPTS="-o UserKnownHostsFile=$2"
+ shift
+ shift
+else
+ SSH_KNOWN_HOSTS_OPTS=''
+fi
+
HOSTS=$1
shift
@@ -16,7 +24,7 @@
fi
# Don't wait too long for inaccessible hosts.
-SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes"
+SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes -o StrictHostKeyChecking=yes
$SSH_KNOWN_HOSTS_OPTS"
TMP=`mktemp -t -d`
sed -e 's/#.*//' -e '/^[ \t]*$/d' $HOSTS > $TMP/hosts
Modified: trunk/distcomp/scripts/rshpar.sh
==============================================================================
--- trunk/distcomp/scripts/rshpar.sh (original)
+++ trunk/distcomp/scripts/rshpar.sh Wed Dec 3 12:21:00 2008
@@ -2,7 +2,7 @@
if [ $# -lt 2 ]; then
echo "Executes the command in parallel. Usage:"
- echo "$0 [ -q | --quiet ] hosts_file remote_command"
+ echo "$0 [ -q | --quiet ] [ --ssh known_hosts ] hosts_file remote_command"
exit 1
fi
@@ -11,10 +11,18 @@
shift
fi
+if [ "$1" == "--ssh" ]; then
+ SSH_KNOWN_HOSTS_OPTS="-o StrictHostKeyChecking=yes -o UserKnownHostsFile=$2"
+ shift
+ shift
+else
+ SSH_KNOWN_HOSTS_OPTS=''
+fi
+
HOSTS=$1
shift
-SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes"
+SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes $SSH_KNOWN_HOSTS_OPTS"
TMP=`mktemp -t -d`
sed -e 's/#.*//' -e '/^[ \t]*$/d' $HOSTS > $TMP/hosts
Modified: trunk/distcomp/scripts/rshseq.sh
==============================================================================
--- trunk/distcomp/scripts/rshseq.sh (original)
+++ trunk/distcomp/scripts/rshseq.sh Wed Dec 3 12:21:00 2008
@@ -2,7 +2,7 @@
if [ $# -lt 2 ]; then
echo "Executes the command sequentially. Usage:"
- echo "$0 [ -q | --quiet ] hosts_file remote_command"
+ echo "$0 [ -q | --quiet ] [ --ssh known_hosts ] hosts_file remote_command"
exit 1
fi
@@ -11,10 +11,18 @@
shift
fi
+if [ "$1" == "--ssh" ]; then
+ SSH_KNOWN_HOSTS_OPTS="-o StrictHostKeyChecking=yes -o UserKnownHostsFile=$2"
+ shift
+ shift
+else
+ SSH_KNOWN_HOSTS_OPTS=''
+fi
+
HOSTS=$1
shift
-SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes"
+SSH_OPTS="-o ConnectTimeout=2 -o BatchMode=yes $SSH_KNOWN_HOSTS_OPTS"
TMP=`mktemp -t -d`
sed -e 's/#.*//' -e '/^[ \t]*$/d' $HOSTS > $TMP/hosts