Return to Snippet

Revision: 55643
at February 15, 2012 08:35 by cruelfate


Updated Code
#! /bin/bash

if [ $# -eq 0 ] ; then 
    echo usage: $0 command
    exit 1
fi

for h in $(cat ~/.ssh/known_hosts | cut -f 1 -d  ' ' | cut -f 1 -d , | sort )
do 
    ping -q -o $h > /dev/null && echo -n "$h: " && ssh $h $*
done

Revision: 55642
at February 15, 2012 08:21 by cruelfate


Initial Code
#! /bin/bash

if [ $# -eq 0 ] ; then 
    echo usage: $0 command
    exit 1
fi

for h in $(cat ~/.ssh/known_hosts | cut -f 1 -d  ' ' | cut -f 1 -d , | grep -E "plab|wddl.il|bos.ma" | sort )
do 
    ping -q -o $h > /dev/null && echo -n "$h: " && ssh $h $*
done

Initial URL

                                

Initial Description
Perform command on all hosts found in **~/.ssh/known_hosts**

Works better when [**auth.sh**](http://snipplr.com/view/46699/authsh/ "auth.sh") has been run on each host first.

Initial Title
Run command on all hosts in known_hosts file

Initial Tags
Bash, ssh

Initial Language
Bash