Linux equivalent to PowerShell's "one-to-many" remoting
Summary
- Ansible is a DevOps tool that is a powerful replacement for PowerShell
- RunDeck as a graphical interface is handy
- Some people run RunDeck+Ansible together
clusterssh
For sending remote commands to several servers, for a beginner, I would recommend clusterssh
To install clusterssh
in Debian:
apt-get install clusterssh
Another clusterssh tutorial:
ClusterSSH is a Tk/Perl wrapper around standard Linux tools like XTerm and SSH. As such, it'll run on just about any POSIX-compliant OS where the libraries exist — I've run it on Linux, Solaris, and Mac OS X. It requires the Perl libraries Tk (perl-tk on Debian or Ubuntu) and X11::Protocol (libx11-protocol-perl on Debian or Ubuntu), in addition to xterm and OpenSSH.
Ansible
As for a remote framework for multiple systems administration, Ansible is a very interesting alternative to Puppet. It is more lean, and it does not need dedicated remote agents as it works over SSH (it also has been bought by RedHat)
The Playbooks are more elaborate than the command line options.
However, to start using Ansible you need a simple installation and to setup the clients list text file.
Afterwards, to run a command in all servers, it is as simple as doing:
ansible all -m command -a "uptime"
The output also is very nicely formatted and separated per rule/server, and while running it in the background can be redirected to a file and consulted later.
You can start with simple rules, and Ansible usage will get more interesting as you grow in Linux, and your infra-structure becomes larger. As such it will do so much more than PowerShell.
As an example, a very simple Playbook to upgrade Linux servers that I wrote:
---
- hosts: all
become: yes
gather_facts: False
tasks:
- name: updates a server
apt: update_cache=yes
- name: upgrade a server
apt: upgrade=full
It also has many modules defined that let you easily write comprehensive policies.
Module Index - Ansible Documentation
It also has got an interesting official hub/"social" network of repositories to search for already made ansible policies by the community. Ansible Galaxy
Ansible is also widely used, and you will find lots of projects in github, like this one from myself for FreeRadius setup.
While Ansible is a free open source framework, it also has a paid web panel interface, Ansible Tower although the licensing is rather expensive.
Nowadays, after RedHat bought it, tower has also the open source version known as AWX.
As a bonus, Ansible also is capable of administering Windows servers, though I have never used it for that.
It is also capable of administering networking equipment (routers, switches, and firewall), which make it a very interesting solution as an automation turn key solution.
How to install Ansible
Rundeck
Yet again, for a remote framework easier to use, but not so potent as Ansible, I do recommend Rundeck.
It is a very powerful multi-user/login graphical interface where you can automate much of your common day-to-day tasks, and even give watered down views to sysops or helpdesk people.
When running the commands, it also gives you windows with the output broken down by server/task.
It can run multiple jobs in the background seamlessly, and allows you to see the report and output later on.
How to install RunDeck
Please note there are people running Ansible+RunDeck as a web interface; not all cases are appropriated for that.
It also goes without saying that using Ansible and/or RunDeck can be construed as a form or part of the infra-structure documentation, and over time allows to replicate and improve the actions/recipes/Playbooks.
Lastly, talking about a central command server, I would create one just up for the task. Actually the technical term is a jump box. 'Jump boxes' improve security, if you set them up right.
If you want to do it interactively, you can use terminator
which allows to broadcast a command to multiple terminals.
See: How do I run the same linux command in more than one tab/shell simultaneously?
You can also use pssh
(or parallel-ssh
), which is an SSH client that connects to a list of hosts and executes the command on all hosts in parallel:
$ parallel-ssh -i -H "host1 host2" uname -a
[1] 11:37:12 [SUCCESS] host2
Linux host2 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[2] 11:37:12 [SUCCESS] host1
Linux host1 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux