pssh 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

pssh 命令安装:


-bash/zsh: pssh: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install pssh

# Debian
apt-get install pssh

# Ubuntu
apt-get install pssh

# Alpine
apk add pssh

# Kali Linux
apt-get install pssh

# Fedora
dnf install pssh

# OS X
brew install pssh

# Raspbian
apt-get install pssh

# Dockerfile
 dockerfile.run/pssh

# Docker
docker run cmd.cat/pssh pssh

pssh 命令补充说明:


pssh 全称为 parallel-ssh,是一个用 Python 编写的可以并发在多台服务器上批量执行命令的工具。

提供了一系列命令如 pssh、pscp、prsync、pnuke 和 pslurp,支持远程并行执行命令、杀掉进程、复制文件等等,是十分方便的批量管理主机的命令。使用 pssh 相关命令时不需要在受控节点上安装任何类似 agent 的东西,只需要在管理节点上安装 pssh,然后让管理节点可以通过 ssh 登录受控节点即可。

在容器化大行其道的今天,对机器节点本身进行操作的需求在减少,但是 pssh 命令仍然有它适合的使用场景。

pssh 命令语法:


pss [ -fLkrSPv ] [ -s cell ] [ -R n ] [ -C n ] [ -n n ] [ -d c ]

pssh 扩展工具


  • parallel-ssh (pssh) 在多个主机上并行地运行命令。
  • parallel-scp (pscp)把文件并行地复制到多个主机上。
  • parallel-rsync (psync)通过 rsync 协议把文件高效地并行复制到多个主机上。
  • parallel-slurp (pslurp)把文件并行地从多个远程主机复制到中心主机上。
  • parallel-nuke (pnuke)并行地在多个远程主机上杀死进程。

pssh 命令选项:


Options:


       -f     Omit column width calculations.  This option is for preparing data
              to be merged with an existing spreadsheet.  If the option is not
              specified, the column widths calculated for the data read by pss
              will override those already set in the existing spreadsheet.


       -L     Left justify strings.


       -k     Keep all delimiters.  This option causes the output cell to change
              on each new delimiter encountered in the input stream.   The
              default action is to condense multiple delimters to one, so that
              the cell only changes once per input data item.


       -r     Output the data by row first then column.  For input consisting of
              a single column, this option will result in output of one row with
              multiple columns instead of a single column spread sheet.


       -s cell
              Start the top left corner of the spread sheet in cell.  For
              example, -s B33 will arrange the output data so that the spread
              sheet starts in column B, row 33.


       -R n   Increment by n on each new output row.


       -C n   Increment by n on each new output column.


       -n n   Output n rows before advancing to the next column.  This option is
              used when the input is arranged in a single column and the spread
              sheet is to have multiple columns, each of which is to be length
              n.


       -d c   Use the single character c as the delimiter between input fields.


       -P     Plain numbers only.  A field is a number only when there is no
              imbeded [-+eE].


       -S     All numbers are strings.


       -v     Print the version of pss

pssh 命令参数:


主机信息

pssh 命令实例:


pssh 在两台主机上运行命令,并在每台服务器上内联打印其输出:

pssh -i -H "host1 host2" hostname -i

pssh 在两台主机上运行命令,并在每台服务器上内联打印其输出:

pssh -H host1 -H host2 -o path/to/output_dir hostname -i

pssh 命令扩展阅读:




pssh 命令评论