Polysh简单的来说就是允许在一个shell中同时向多个远程主机发送命令进行批量化交互式操作,执行的结果会直接打印在当前shell,使用与简单的交互式批量化管理主机,以下为官方简介:
Polysh (formerly called Group Shell or gsh) is a remote shell multiplexer. 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. It requires only a SSH server on the remote hosts, or some other way to open a remote shell.
官方版本要求: need Python ≥ 2.4
安装
pip安装
直接pip安装即可,亲测python版本大于2.6都能够正常执行
pip install polysh
源码安装
使用以下命令下载安装,安装完成后Linux下看一看到/usr/bin/polysh
,没有的话可以自己创建软链。
wget http://guichaz.free.fr/polysh/files/polysh-0.4.tar.gz
tar -zxvf polysh-0.4.tar.gz
cd polysh-0.4
sudo python setup.py install
使用
常规使用
一般使用可以把要操作的主机host保存在一个file中,使用--hosts-file
指定主机名文件,使用--user
指定用户
polysh --hosts-file my_host --user root
ready (6)>
主机名一致
例如要登陆一下四台主机:
host_name01
host_name02
host_name03
host_name04
执行一下命令即可
polysh 'host_name<01-14>'
waiting (1/4)>
其他用法
更多参数参考:https://github.com/innogames/polysh
polysh
usage: /usr/bin/polysh [OPTIONS] HOSTS...
Control commands are prefixed by ":".
[-h] [--hosts-file FILE] [--command CMD] [--ssh SSH] [--user USER]
[--no-color] [--password-file FILE] [--log-file LOG_FILE]
[--abort-errors] [--debug] [--profile]
[host_names [host_names ...]]
/usr/bin/polysh [OPTIONS] HOSTS...
Control commands are prefixed by ":".: error: no hosts given
此外源代码很少,有兴趣可以阅读一下源码!