From 6ec39abcb8b527618919c6d3c9d9bbc81cb83d04 Mon Sep 17 00:00:00 2001 From: James Brown Date: Tue, 27 Jan 2015 20:55:26 -0800 Subject: [PATCH 1/2] completely ignore known hosts file if SSH_LIST_IGNORE_HOST_KEYS is set to "1" --- contrib/bin/user-ssh-list | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/bin/user-ssh-list b/contrib/bin/user-ssh-list index 32cc829..873c316 100755 --- a/contrib/bin/user-ssh-list +++ b/contrib/bin/user-ssh-list @@ -26,8 +26,12 @@ if [ "$query" = "all" ] ; then query="(clusto_type=server)" fi export CLUSTO_TYPE_FILTER="server" +args="" +if [ "$SSH_LIST_IGNORE_HOST_KEYS" -eq 1 ]; then + args="$args -o UserKnownHostsFile=/dev/null" +fi for h in $($CLUSTO $query | sort) ; do - ping -w1 -c1 -q $h > /dev/null 2>&1 + ping -w1 -c1 -q "$h" > /dev/null 2>&1 if [ $? -ne 0 ]; then continue fi @@ -36,5 +40,6 @@ for h in $($CLUSTO $query | sort) ; do else sed_cmd="s,^,$h | ," fi - ( ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no -l $username $h -- "$@" 2>&1 ) | sed -e "$sed_cmd" + $ar + ( ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no $args -l "$username" "$h" -- "$@" 2>&1 ) | sed -e "$sed_cmd" done From 912b7ac42b4e06f5b352b541888d4e866a60def9 Mon Sep 17 00:00:00 2001 From: James Brown Date: Wed, 28 Jan 2015 10:16:09 -0800 Subject: [PATCH 2/2] pass through in -async oto --- contrib/bin/user-ssh-list-async | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/bin/user-ssh-list-async b/contrib/bin/user-ssh-list-async index 2617668..ca991ba 100755 --- a/contrib/bin/user-ssh-list-async +++ b/contrib/bin/user-ssh-list-async @@ -17,10 +17,13 @@ def run_command_on(host, command, username): except Exception: print >>sys.stderr, 'Could not ping %s, moving on' % host return - cmd = [ + base_cmd = [ '/usr/bin/ssh', '-o', 'ConnectTimeout=3', '-o', - 'StrictHostKeyChecking=no', '-l', username, host, - ] + command + 'StrictHostKeyChecking=no', '-l', username, + ] + if os.environ.get('SSH_LIST_IGNORE_HOST_KEYS', False): + base_cmd += ['-o', 'UserKnownHostsFile=/dev/null'] + cmd = base_cmd + [host] + command p = subprocess.Popen( cmd,