linux批量管理推送工具mussh和pssh介紹
來(lái)源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2018-04-17 06:10┆點(diǎn)擊:
mussh 是shell開(kāi)發(fā)的一個(gè)小工具,pssh是python開(kāi)發(fā)的一個(gè)用來(lái)批量管理linux主機(jī)的工具,現(xiàn)在我們來(lái)介紹mussh和pssh的使用方法。
先說(shuō)下mussh,mussh 是shell開(kāi)發(fā)的一個(gè)小工具,剛學(xué)習(xí)運(yùn)維和shell的朋友可以拿來(lái)鍛煉下,做個(gè)工具的二次開(kāi)發(fā)。
[root@devops-ruifengyun ~ ]$ apt-get install mussh
正在讀取軟件包列表... 完成
正在分析軟件包的依賴(lài)關(guān)系樹(shù)
正在讀取狀態(tài)信息... 完成
下列軟件包是自動(dòng)安裝的并且現(xiàn)在不需要了:
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
升級(jí)了 0 個(gè)軟件包,新安裝了 1 個(gè)軟件包,要卸載 0 個(gè)軟件包,有 205 個(gè)軟件包未被升級(jí)。
需要下載 14.4 kB 的軟件包。
解壓縮后會(huì)消耗掉 71.7 kB 的額外空間。
獲取:1 saucy/universe mussh all 1.0-1 [14.4 kB]
下載 14.4 kB,耗時(shí) 0秒 (30.3 kB/s)
Selecting previously unselected package mussh.
(正在讀取數(shù)據(jù)庫(kù) ... 系統(tǒng)當(dāng)前共安裝有 234998 個(gè)文件和目錄。)
正在解壓縮 mussh (從 .../archives/mussh_1.0-1_all.deb) ...
正在處理用于 man-db 的觸發(fā)器...
正在設(shè)置 mussh (1.0-1) ...
[root@devops-ruifengyun ~ ]$
mussh的幫助,會(huì)看到他的幫助相當(dāng)?shù)暮?jiǎn)單。
代碼如下
[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 ./linuxhosts -C spfiles/testscript.sh
mussh -c "cat /etc/hosts" -h myhost.mydomain.com
Comments and Bug Reports: doughnut@doughnut.net