当前位置 : 主页 > 网络安全 > 测试自动化 >

PSSH工具

来源:互联网 收集:自由互联 发布时间:2021-06-19
目录 PSSH工具 参考 PSSH工具的介绍 PSSH工具的使用 PSSH工具 ?? Written by Zak Zhu 参考 Dicky_Zhang/运维自动化轻量级工具pssh(https://www.cnblogs.com/Dicky-Zhang/p/5988415.html) PSSH工具的介绍 pssh是python写的

目录

  • PSSH工具
    • 参考
    • PSSH工具的介绍
    • PSSH工具的使用

PSSH工具

?? Written by Zak Zhu

参考

  • Dicky_Zhang/运维自动化轻量级工具pssh(https://www.cnblogs.com/Dicky-Zhang/p/5988415.html)

PSSH工具的介绍

pssh是python写的可以并发在多台机器上批量执行命令的工具, 它的用法可以媲美ansible的一些简单用法, 执行起来速度比ansible快. 它支持文件并行复制, 远程命令执行, 杀掉远程主机上的进程等

PSSH工具的使用

在使用pssh之前, 建议跳板机和远程主机做好ssh公钥认证

安装

wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/parallel-ssh/pssh-2.3.1.tar.gz
tar -zxvf pssh-2.3.1.tar.gz
cd pssh-2.3.1
python setup.py install

pssh命令

在远程多台主机上并行执行命令

pssh [OPTIONS] command
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "[email protected][:port]")
    -i  # inline aggregate output and error for each server
    -o OUTDIR   # output dir for stdout files, OUTDIR is on the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

vi /tmp/host_file   # host file (each line "[email protected][:port]")
pssh -h /tmp/host_file -i ls -l /root

pscp命令

把文件并行复制到多台远程主机上

pscp [OPTIONS] local remote
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "[email protected][:port]")
    -r  # recursively copy dir
    -o OUTDIR   # output dir for stdout files, OUTDIR is in the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

pscp -h /tmp/host_file /tmp/test /tmp/

pslurp命令

把文件从远程多台主机上复制到本地主机上

pslurp [OPTIONS] remote local
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "[email protected][:port]")
    -r  # recursively copy dir
    -L LOCALDIR # output dir for remote file copies
    -o OUTDIR   # output dir for stdout files, OUTDIR is in the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

pslurp -h /tmp/host_file -L /tmp/ /tmp/test test
# 上边是, 将/tmp/host_file写的远程主机上的/tmp/test文件复制到本地主机/tmp/目录下, 并且重新命名为test文件

pnuke命令

在远程多台主机上并行killall某一进程

pnuke [OPTIONS] pattern
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "[email protected][:port]")
    -o OUTDIR   # output dir for stdout files, OUTDIR is in the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

pnuke -h /tmp/host_file java
网友评论