mussh 是shell开发的一个小工具,pssh是python开发的一个用来批量管理linux主机的工具,现在我们来介绍mussh和pssh的使用方法。
先说下mussh,mussh 是shell开发的一个小工具,刚学习运维和shell的朋友可以拿来锻炼下,做个工具的二次开发。
[root@devops-ruifengyun ~ ]$ apt-get install mussh
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
kde-l10n-engb kde-l10n-zhcn libffi6:i386 libglib2.0-0:i386
libsystemd-daemon0:i386 libudev1:i386 python-async python-git python-gitdb
python-smmap
Use 'apt-get autoremove' to remove them.
下列【新】软件包将被安装:
mussh
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 205 个软件包未被升级。
需要下载 14.4 kB 的软件包。
解压缩后会消耗掉 71.7 kB 的额外空间。
获取:1 saucy/universe mussh all 1.0-1 [14.4 kB]
下载 14.4 kB,耗时 0秒 (30.3 kB/s)
Selecting previously unselected package mussh.
(正在读取数据库 ... 系统当前共安装有 234998 个文件和目录。)
正在解压缩 mussh (从 .http://www.jsgho.com/help/archives/mussh_1.0-1_all.deb) ...
正在处理用于 man-db 的触发器...
正在设置 mussh (1.0-1) ...
[root@devops-ruifengyun ~ ]$
mussh的帮助,会看到他的帮助相当的简单。 代码如下
[root@devops-ruifengyun ~ ]$ mussh --help
Usage: mussh [OPTIONS] <-h host.. | -H hostfile> [-c cmd] [-C scriptfile]
mussh --help for full help text
Send a command or list of commands to multiple hosts.
OPTIONS:
--help This text.
-d [n] Verbose debug. Prints each action, all hosts
and commands to be executed to STDERR. 'n' can
be from 0 to 2.
-v [n] Ssh debug levels. Can be from 0 to 3.
-m [n] Run concurrently on 'n' hosts at a time (asynchronous).
Use '0' (zero) for infinite. (default if -m)
-q No output unless necessary.
-i <identity> [identity ..]
Load an identity file. May be used
more than once.
-o <ssh-args> Args to pass to ssh with -o option.
-a Force loading ssh-agent.
-A Do NOT load ssh-agent.
-b Print each hosts' output in a block without mingling
with other hosts' output.
-B Allow hosts' output to mingle. (default)
-u Unique. Eliminate duplicate hosts. (default)
-U Do NOT make host list unique.
-P Do NOT fall back to passwords on any host. This will
skip hosts where keys fail.
-l <login> Use 'login' when no other is specified with hostname.
-L <login> Force use of 'login' name on all hosts.
-s <shell> Path to shell on remote host. (Default: bash)
-t <secs> Timeout setting for each session.
(requires openssh 3.8 or newer)
-V Print version info and exit.
PROXY ARGS:
-p [user@]<host>
Host to use as proxy. (Must have mussh installed)
-po <ssh-args> Args to pass to ssh on proxy with -o option.
HOST ARGS:
-h [user@]<host> [[user@]<host> ..]
Add a host to list of hosts. May be
used more than once.
-H <file> [file ..]
Add contents of file(s) to list of hosts.
Files should have one host per line. Use
"#" for comments.
COMMAND ARGS:
If neither is specified, commands will be read from standard input.
-c <command> Add a command or quoted list of commands and
args to list of commands to be executed on
each host. May be used more than once.
-C <file> [file ..]
Add file contents to list of commands to be
executed on each host. May be used more
than once.
At least one host is required. Arguments are in no particular order.
EXAMPLES:
mussh -H http://www.jsgho.com/help/fwq/linuxhosts -C spfiles/testscript.sh
mussh -c "cat /etc/hosts" -h myhost.mydomain.com
Comments and Bug Reports: doughnut@doughnut.net