|
NAMEpssh — parallel ssh programSYNOPSISpssh [-vAiIP] [-h hosts_file] [-H [user@]host[:port]] [-g pattern] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout] [-O options] [-x args] [-X arg] command ...pssh -I [-vAiIP] [-h hosts_file] [-H [user@]host[:port]] [-g pattern] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout] [-O options] [-x args] [-X arg] [command ...] DESCRIPTIONpssh is a program for executing ssh in parallel on a number of hosts. It provides features such as sending input to all of the processes, passing a password to ssh, saving output to files, and timing out.The PSSH_NODENUM, PSSH_NUMNODES, PSSH_HOST environment variables are sent to the remote host. The PSSH_NODENUM variable is assigned a unique number for each ssh connection, starting with 0 and counting up. The PSSH_NUMNODES variable is assigned the total number of node being used. The PSSH_HOST variable is assigned the name of the host as specified in the hosts list. Note that sshd drops environment variables by default, so sshd_config on the remote host must include the line: AcceptEnv PSSH_NODENUM PSSH_NUMNODES PSSH_HOST
OPTIONS
EXAMPLESConnect to host1 and host2, and print "hello, world" from each:pssh -i -H "host1 host2" echo "hello,
world"
Print "hello, world" from each host specified in the file hosts.txt: pssh -i -h hosts.txt echo "hello, world"
Run a command as root with a prompt for the root password: pssh -i -h hosts.txt -A -l root echo hi
Run a long command without timing out: pssh -i -h hosts.txt -t 0 sleep 10000
If the file hosts.txt has a large number of entries, say 100, then the parallelism option may also be set to 100 to ensure that the commands are run concurrently: pssh -i -h hosts.txt -p 100 -t 0 sleep 10000
Run a command without checking or saving host keys: pssh -i -H host1 -H host2 -x "-O
StrictHostKeyChecking=no -O UserKnownHostsFile=/dev/null -O
GlobalKnownHostsFile=/dev/null" echo hi
Print the node number for each connection (this will print 0, 1, and 2): pssh -i -H host1 -H host1 -H host2 'echo
$PSSH_NODENUM'
TIPSIf you have a set of hosts that you connect to frequently with specific options, it may be helpful to create an alias such as:alias pssh_servers="pssh -h /path/to/server_list.txt
-l root -A"
Note that when an ssh command is terminated, it does not kill remote processes (OpenSSH bug #396 has been open since 2002). One workaround is to instruct ssh to allocate a pseudo-terminal, which makes it behave more like a normal interactive ssh session. To do this, use pssh's "-x" option to pass "-tt" to ssh. For example: pssh -i -x "-tt" -h hosts.txt -t 10 sleep
1000
will ensure that all of the sleep commands will terminate (with SIGHUP) after
the 10 second timeout.
By default, ssh uses full buffering for non-interactive commands. Line buffering may be preferrable to full buffering if you intend to look at the files in an output directory as a command is running. To switch ssh to use line buffering, use its "-tt" option (which allocates a pseudo-terminal) using the "-x" option in pssh. The ssh_config file can include an arbitrary number of Host sections. Each host entry specifies ssh options which apply only to the given host. Host definitions can even behave like aliases if the HostName option is included. This ssh feature, in combination with pssh host files, provides a tremendous amount of flexibility. EXIT STATUSThe exit status codes from pssh are as follows:
AUTHORSWritten by Brent N. Chun <bnc@theether.org> and Andrew McNabb <amcnabb@mcnabbs.org>.https://github.com/lilydjwg/pssh SEE ALSOssh(1), ssh_config(5), pscp(1), prsync(1), pslurp(1), pnuke(1),
Visit the GSP FreeBSD Man Page Interface. |