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.


== 下载安装 ==

下载

[plain]  view plain copy print ?
  1. wget http://parallel-ssh.googlecode.com/files/pssh-2.3.1.tar.gz  

安装
[plain]  view plain copy print ?
  1. tar xf pssh-2.3.1.tar.gz  
  2. cd pssh-2.3.1/  
  3. 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
[plain]  view plain copy print ?
  1. $ pssh -h ip.txt -l root chkconfig --level 2345 snmpd on  
  2. [1] 10:59:29 [SUCCESS] ... ...  
  3. [2] 10:59:29 [SUCCESS] ... ...  
  4. [3] 10:59:29 [SUCCESS] ... ...  
  5. ... ...  

pscp
[plain]  view plain copy print ?
  1. $ pscp -h ip.txt -l root /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf  
  2. [1] 11:00:42 [SUCCESS] ... ...  
  3. [2] 11:00:42 [SUCCESS] ... ...  
  4. [3] 11:00:42 [SUCCESS] ... ...  
  5. ... ...  


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


转自:http://blog.csdn.net/kumu_linux/article/details/8562320

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值