pssh

== 簡介 ==
pssh是一個python編寫可以在多臺服務器上執行命令的工具,同時支持拷貝文件,是同類工具中很出色的,類似pdsh,個人認爲相對pdsh更爲簡便,使用必須在各個服務器上配置好密鑰認證訪問,這樣才能達到批量部署的簡便。
項目地址:https://code.google.com/p/parallel-ssh/

PSSH provides parallel versions of OpenSSH and related tools. Included are pssh, pscp, prsync, pnuke, and pslurp. The project includes psshlib which can be used within custom applications. The source code is written in Python and can be cloned from:

git clone http://code.google.com/p/parallel-ssh/

PSSH is supported on Python 2.4 and greater (including Python 3.1 and greater). It was originally written and maintained by Brent N. Chun. Due to his busy schedule, Brent handed over maintenance to Andrew McNabb in October 2009.

== 下載安裝 ==

下載

wget http://parallel-ssh.googlecode.com/files/pssh-2.3.1.tar.gz

安裝

tar xf pssh-2.3.1.tar.gz
cd pssh-2.3.1/
python setup.py install


== 參數命令介紹 ==

'''介紹pssh參數'''
 

pssh   在多個主機上並行地運行命令
-h 執行命令的遠程主機列表 或者 -H user@ip:port 文件內容格式[user@]host[:port]
-l 遠程機器的用戶名
-P顯示執行輸出
-p 一次最大允許多少連接
-o 輸出內容重定向到一個文件
-e 執行錯誤重定向到一個文件
-t 設置命令執行的超時時間
-A 提示輸入密碼並且把密碼傳遞給ssh
-O 設置ssh參數的具體配置,參照ssh_config配置文件
-x 傳遞多個SSH 命令,多個命令用空格分開,用引號括起來
-X 同-x 但是一次只能傳遞一個命令
-i 顯示標準輸出和標準錯誤在每臺host執行完畢後

'''其他命令'''
pscp 傳輸文件到多個hosts,類似scp
pslurp 從多臺遠程機器拷貝文件到本地
pnuke 並行在遠程主機殺進程
prsync 使用rsync協議從本地計算機同步到遠程主機


== 實例 ==
pssh

$ pssh -h ip.txt -l root chkconfig --level 2345 snmpd on
[1] 10:59:29 [SUCCESS] ... ...
[2] 10:59:29 [SUCCESS] ... ...
[3] 10:59:29 [SUCCESS] ... ...
... ...


pscp

$ pscp -h ip.txt -l root /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf
[1] 11:00:42 [SUCCESS] ... ...
[2] 11:00:42 [SUCCESS] ... ...
[3] 11:00:42 [SUCCESS] ... ...
... ...

參考:http://my.oschina.net/guol/blog/59977

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章