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
- Best AI tools for Software Engineers - November 4, 2024
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024