Broadcast a Command with SSH
July 18, 2004
Use ssh to broadcast a command to a list of hosts given that you've already setup ssh keys and the login is automatic.
#!/bin/bash # # This is a sample script to "broadcast" a command via ssh to a set of computers # each server to distribute to DHOSTS="host1 host2 host3"; # Loop through each server and distributes each file for DHOST in $DHOSTS; do echo "Working on host $DHOST with command $1"; ssh $DHOST $1; done
2 Comments