gsh - Run linux commands on many other linux server at once

gsh - Run linux commands on many other linux server at once

Group Shell (also called gsh) is a remote shell multiplexor. It lets you control many remote shells at once in a single shell. Unlike other commands dispatchers, it is interactive, so shells spawned on the remote hosts are persistent.

GSH is a pluggable version of DSH (Distributed Shell) written in Python. Both a module and a command-line tool for running a shell command over multiple machines are included. GSH can be extended by adding new host loaders as well as hooking into various stages of the runtime.

It requires only a SSH server on the remote hosts, or some other way to open a remote shell.
gsh allows you to run commands on multiple hosts by adding tags to the gsh command.

e.g > gsh tag "remote command"

Important things to remember:
/etc/ghosts contains a list of all the servers and tags. gsh is a lot more fun once you’ve set up ssh keys to your servers

gsh [OPTIONS] SYSTEMS CMD...
SYSTEMS is a combination of ghost macros. See ghosts(1).

CMD is the command to run
-h, --help Display full help
-d, --debug Turn on exeuction debugging reports
-h, --no-host-prefix Does not prefix output lines with the host name
-s, --show-commands Displays the command before the output report
-n, --open-stdin Leaves stdin open when running (scary!)
-l, --user USER SSH's to the host as user USER
-r, --run-locally Run commands locally (replaces $host with host)
-o, --self-remote Run locally instead of over SSH for local host
-V, --version Report the version and exit

You set up a /etc/ghosts file containing your servers in groups such as web, db, RHEL4, x86_64, or whatever (man ghosts) then you use that group when you call gsh.

How to run the gsh?
> gsh linux "cat /etc/redhat-release; uname -r"

You can also combine or split ghost groups, using cpanel+vps or web-RHEL4, for example.

Here’s an example /etc/ghosts file:
# Machines
#
# hostname OS-Version Hardware OS cp security
linuxbrigade.com debian6 baremetal linux plesk iptables
linuxbrigade.com centos5 vps linux cpanel csfcluster
linuxbrigade.com debian7 baremetal linux plesk iptables
linuxbrigade.com centos6 vps linux cpanel csfcluster
linuxbrigade.com centos6 vps linux cpanel csfcluster
linuxbrigade.com centos6 vps linux nocp denyhosts
linuxbrigade.com debian6 baremetal linux plesk iptables
linuxbrigade.com centos6 baremetal linux cpanel csf
linuxbrigade.com centos5 vps linux cpanel csf

Reference url

http://www.linuxbrigade.com/run-the-same-command-on-many-linux-servers-at-once/
http://linux.die.net/man/1/gsh
https://github.com/gmjosack/gsh
http://outflux.net/unix/software/gsh/
http://outflux.net/unix/software/gsh/gsh.html

Rate this item
(0 votes)
Rajesh Kumar

.

Total, Over 12 years of extensive experience in the Software Configuration Management domain having depth knowledge of DevOps, Continuous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.

What corporate management say about us?

Rajesh is very knowledgeable instructor he has a good exposure on real time issue and case studies he is experienced in large environment issue and challenges. I really liked how Rajesh used a lot of examples so that concepts were more easily understood, I like the examples that Rajesh give to help us remember things…they are usually real scenario, real life problems that we encounter frequently. <br /> He is well organised in terms of study materiel that you can refer anytime after you complete your course. His blogs are crisp and has to the point key content that he discussed during session to remember if you refer them remotely.

Gaurav Vishnoi
I am having 11+ years of experience in java, due to increasing complexity of system and environment I opted for this tanning and find it very useful., Noida
Sep 02, 2016

Authors

Login