Ever have to check a list of Linux servers for various things like what version of CentOS they’re running, maybe how long each has been running to get an uptime report? You can – and it’s very easy to get going with it.
gsh allows you to run commands on multiple hosts by adding tags to the gsh command.
1 |
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
Examples to use:
List uptime on all servers in the linux group:
1 |
gsh linux "uptime" |
Check to see if an IP address was blocked with CSF by checking the csf and csfcluster groups/tags:
1 |
gsh csf+csfcluster "/usr/sbin/csf -g xxx.xxx.xxx.xxx" |
Unblock an IP and remove from /etc/csf.deny from all csf and csfcluster machines
1 |
gsh csf+csfcluster "/usr/sbin/csf -dr xxx.xxx.xxx.xxx" |
Check the linux kernel version on all VPS machines running centos 5
1 |
gsh centos5-baremetal "uname -r" |
Check cpanel version on all cpanel machines
1 |
gsh cpanel "/usr/local/cpanel/cpanel -V" |
The full readme is located here: http://outflux.net/unix/software/gsh/
Here’s an example /etc/ghosts file:
1 2 3 4 5 6 7 8 9 10 11 12 |
# Machines # # hostname OS-Version Hardware OS cp security 1.linuxbrigade.com debian6 baremetal linux plesk iptables 2.linuxbrigade.com centos5 vps linux cpanel csfcluster 3.linuxbrigade.com debian7 baremetal linux plesk iptables 4.linuxbrigade.com centos6 vps linux cpanel csfcluster 5.linuxbrigade.com centos6 vps linux cpanel csfcluster 6.linuxbrigade.com centos6 vps linux nocp denyhosts 7.linuxbrigade.com debian6 baremetal linux plesk iptables 8.linuxbrigade.com centos6 baremetal linux cpanel csf 9.linuxbrigade.com centos5 vps linux cpanel csf |
That is very useful actually. I use to run each one manually so this will save me a lot of time. Your guides are very easy to follow and thanks for providing the link to the full readme.
Is this the gsh you are using?
http://outflux.net/unix/software/gsh/
Yes it is – sorry about that. I could have put a download link.
That looks like a really cool tool, I will have to test that out. It seems like a great way to manage updates to large groups of machines in a controlled way.
Now I need to set up ssh keys to all of my machines.
Another excellent guide. Thank you. This will improve my productivity quite a bit. Very helpful code, indeed.