parallel-ssh
, parallel-scp , parallel-rsync
, parallel-slurp
and parallel-nuke
(for details on these tools, see the man).parallel-ssh
on a Linux system, you must first install pip
. Here is how it is done in different distributions: $ sudo apt install python-pip python-setuptools #Debian/Ubuntu # yum install python-pip python-setuptools #RHEL/CentOS # dnf install python-pip python-setuptools #Fedora 22+
parallel-ssh
installed using pip
: $ sudo pip install parallel-ssh
hosts
(in fact, you can call it whatever you like). Here we need this command: $ vim hosts
192.168.0.10:22 192.168.0.11:22 192.168.0.12:22
parallel-ssh
by passing the file name to this utility using the -h
option, as well as the commands that need to be run on all servers whose addresses are in the hosts
. The utility -i
flag is used to display what gets into the standard output and error streams after completing the execution of commands on the servers.parallel-ssh
startup command might look like this: $ parallel-ssh -h hosts "uptime; df -h"
pdsh
in various distributions: $ sudo apt install pdsh #Debian/Ubuntu # yum install pdsh #RHEL/CentOS # dnf install pdsh #Fedora 22+
parallel-ssh
, must be added to a file, which can also be called hosts
. Then you need to run pdsh
as follows: $ pdsh -w ^hosts -R ssh "uptime; df -h"
-w
flag is used to specify the file with the list of servers, the -R
flag is used to specify the remote command module (among the available remote command modules are ssh
, rsh
, exec
; rsh
used by default). Notice the ^
icon in front of the server list file name.pdsh
, did not specify a list of commands to be executed on the servers, this utility will run interactively. Details on pdsh
can be found on the corresponding man page.xterm
window. After that on all these servers it is possible to simultaneously execute the same commands.clusterssh
: $ sudo apt install clusterssh #Debian/Ubuntu # yum install clusterssh #RHEL/CentOS $ sudo dnf install clusterssh #Fedora 22+
$ clusterssh linode cserver contabo
$ clusterssh username@server1 username@server2 username@server3
ansible
: $ sudo apt install ansible #Debian/Ubuntu # yum install ansible #RHEL/CentOS $ sudo dnf install ansible #Fedora 22+
/etc/ansible/hosts
. $ sudo vim /etc/ansible/hosts
webservers
group: # Ex 2: A collection of hosts belonging to the 'webservers' group [webservers] 139.10.100.147 139.20.40.90 192.30.152.186
uptime
and find out which users are connected to the hosts belonging to the webservers
group, you can use the following construction: $ ansible webservers -a "w " -u admin
-a
option is used to specify the arguments passed to the module, and the -u
flag allows you to set the default username used to connect to remote servers via SSH.ansible
command-line ansible
allows ansible
to execute commands only one at a time.Source: https://habr.com/ru/post/426849/
All Articles