/ Published in: Bash
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.
Works better when [**auth.sh**](http://snipplr.com/view/46699/authsh/ "auth.sh") has been run on each host first.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#! /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