Blog

sshdo, ssh work to bulk hosts

sshdo

Section: User Commands (1)
Updated: September 2009
 

NAME

sshdo --- Execute remote commands or copies via SSH to multiple hosts.  

SYNOPSIS

sshdo [ -h | --help ] [ -v | --version ] [ -m | --man ] [ -mm | --mman ] [ -f | --force ] -u username [ -r ] [ [ -g | -p ] from to ] [ -s suffix ] [ 'remote command' ]  

DESCRIPTION

sshdo issues remote commands, puts or gets files to all hosts sequentially. Hosts are read from stdin (one per line). sshdo will use SSH key agent, if available, to avoid repetitive password entry.

WARNING: Be sure to validate your command before issuing it. One mistake duplicated across multiple hosts could be catastrophic. Backups are also recommended.  

OPTIONS

Options can be prefixed with either one or two hyphens, and can be abbreviated to any unique prefix. Thus, -v, -ver, and --version are equivalent.

[ -h | --help ]
Print usage and exit.
[ -v | --version ]
Print version number an exit.
[ -m | --man ]
Read man page. Goes to stdout.
[ -mm | --mman ]
Make man page. Sends nroff code to stdout.
[ -f | --force ]
Force use of dangerous command or file destination. For example issuing an rm or copying over /etc/passwd.
-u
username Username to use with SSH (e.g. username @hostname or -l username ).
-r
Recursive copy.
-g
Get files from remote location. Followed by from to the source and destination for file copies. Each get is suffixed by '-hostname'.
-p
Put files to remote location. Followed by from to. the ource and destination for file copies.
-s
suffix Save (redirect) output of remote command of each host to local separate file hostname-suffix.
 

EXAMPLES

sshdo -u wally free < hosts
Execute the command free on all hosts listed in the file called hosts. Authenticate using the user wally. The output of free from all hosts is sent to stdout.

sshdo -u wally -s free.txt free < hosts
Same as above but the output of free from all hosts is directed to a separate file, named hostname-free.txt for each host.

sshdo -p myscr.sh /usr/local/bin/
Copy local file myscr.sh to /usr/local/sbin on remote hosts. sshdo will wait for input, one host per line. Terminate input with ctrl-d.
 

AUTHOR

Neil H. Watson, www.watson-wilson.ca, neil-NOSPAM-@watson-wilson.ca  

LICENSE AND COPYING

Copyright 2007 Neil H. Watson

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details <http://www.gnu.org/licenses/>.

DOWNLOAD

sshdo
Time: 23:43:21 GMT, October 09, 2009