linux命令之pssh命令

查看一下pssh命令的帮助文档:

[root@test2 ~]# pssh --version
2.3.1
[root@test2 ~]# pssh --help
Usage: pssh [OPTIONS] command [...]

Options:
  --version             show program's version number and exit
  --help                show this help message and exit
  -h HOST_FILE, --hosts=HOST_FILE
                        hosts file (each line "[user@]host[:port]")
  -H HOST_STRING, --host=HOST_STRING
                        additional host entries ("[user@]host[:port]")
  -l USER, --user=USER  username (OPTIONAL)
  -p PAR, --par=PAR     max number of parallel threads (OPTIONAL)
  -o OUTDIR, --outdir=OUTDIR
                        output directory for stdout files (OPTIONAL)
  -e ERRDIR, --errdir=ERRDIR
                        output directory for stderr files (OPTIONAL)
  -t TIMEOUT, --timeout=TIMEOUT
                        timeout (secs) (0 = no timeout) per host (OPTIONAL)
  -O OPTION, --option=OPTION
                        SSH option (OPTIONAL)
  -v, --verbose         turn on warning and diagnostic messages (OPTIONAL)
  -A, --askpass         Ask for a password (OPTIONAL)
  -x ARGS, --extra-args=ARGS
                        Extra command-line arguments, with processing for
                        spaces, quotes, and backslashes
  -X ARG, --extra-arg=ARG
                        Extra command-line argument
  -i, --inline          inline aggregated output and error for each server
  --inline-stdout       inline standard output for each server
  -I, --send-input      read from standard input and send as input to ssh
  -P, --print           print output as we get it

Example: pssh -h hosts.txt -l irb2 -o /tmp/foo uptime

-h:参数指定主机的文件,主机文件格式如下:

[root@test2 ~]# cat ip.test 
root@10.0.102.162
root@10.0.102.212
root@10.0.102.200

-A: 交互输入密码, -i命令,上面的解释不太清楚,测试如下:

[root@test2 ~]# pssh -h ip.test -A -i w
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password: 
[1] 17:55:21 [SUCCESS] root@10.0.102.212
 16:41:42 up 15 days, 19:20,  2 users,  load average: 0.08, 0.03, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1                      12Feb19 15days  0.01s  0.01s -bash
root     pts/0    172.16.100.19    Tue08    1:38m  6:13   0.13s -bash
[2] 17:55:21 [SUCCESS] root@10.0.102.200
 16:41:46 up 17 days, 9 min,  2 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1                      11Feb19 17days  0.01s  0.01s -bash
root     pts/0    172.16.100.19    Wed15    1:00m  0.03s  0.03s -bash
[3] 17:55:21 [SUCCESS] root@10.0.102.162
 16:41:45 up 17 days, 8 min,  2 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1                      11Feb19 16days  0.07s  0.07s -bash
root     pts/0    172.16.100.19    Wed15    1:00m  0.05s  0.05s -bash
[root@test2 ~]# pssh -h ip.test -A  w
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password: 
[1] 17:55:29 [SUCCESS] root@10.0.102.212
[2] 17:55:30 [SUCCESS] root@10.0.102.162
[3] 17:55:30 [SUCCESS] root@10.0.102.200

批量修改密码:

#把root密码修改为 123456
[root@docker5 ~]# pssh -h ip.test -A "echo root:123456 | chpasswd" Warning: do not enter your password if anyone else has superuser privileges or access to your account. Password: [1] 16:47:48 [SUCCESS] root@10.0.102.200 [2] 16:47:48 [SUCCESS] root@10.0.102.212 [3] 16:47:48 [SUCCESS] root@10.0.102.162

pscp.pssh命令与pslurp命令,一个把本地文件传送到远程主机,一个是把远程主机文件垃下来。

[root@docker5 ~]# pscp.pssh --help
Usage: pscp.pssh [OPTIONS] local remote
[root@docker5 ~]# pscp.pssh -h ip.test roles.tar.gz /usr/local/src/
[1] 16:50:45 [SUCCESS] root@10.0.102.212
[2] 16:50:46 [SUCCESS] root@10.0.102.200
[3] 16:50:46 [SUCCESS] root@10.0.102.162

pnuke    kill远程机器的进程

 

posted @ 2019-02-28 18:08  夜间独行的浪子  阅读(3118)  评论(0编辑  收藏  举报