Chinese user guide of parallel SSH under Linux

iMike 2021-04-16 18:17:24
chinese user guide parallel ssh


parallel-ssh Asynchronous parallel designed for small scale Automation SSH library !

parallel-ssh Asynchronous parallel designed for small scale Automation SSH library , Include psshpscpprsyncpslurp and pnuke Tools , Its source code uses Python Language development of . The project was originally located in Google Code On , By Brent N.Chun Write and maintain , But because of the busy work ,Brent On 2009 year 10 The maintenance work was handed over to Andrew McNabb management . here we are 2012 In the year , because Google Code Is closed , The project was abandoned for a time , Now it can only be Google Code I found the current version in the archives of .

But here's the thing , Previous versions did not support Python3 Of , however Github There are people on it Fork A copy of , They have transformed themselves to support Python3 The above version of . meanwhile , There is also an organization dedicated to parallel-ssh Developed and maintained , I've watched it for a long time, but I haven't updated it . In need , You can check it yourself .

  • lilydjwg/pssh - supported on Python 3.5 and later
  • ParallelSSH/parallel-ssh - asynchronous parallel SSH client library
  • Extensibility
    • Support to expand to 100 , Even thousands of hosts use
  • Easy to use
    • Just two lines of code , You can run commands on any number of hosts
  • Efficient execution
    • Claims to be the fastest Python SSH Libraries are available
  • Use of resources
    • Compared with other Python SSH library , It consumes the least resources
# Mac System installation
$ brew install pssh
# CentOS System installation
$ yum install pssh
# Ubuntu System installation
$ apt install pssh
# PIP install
$ pip insall pssh
# Source code compilation and installation (2.3.1)
# Official address : https://code.google.com/archive/p/parallel-ssh/source/default/source
$ tar zxvf pssh-2.3.1.tar.gz
$ cd pssh-2.3.1
$ python setup.py install

ParallelSSH stay Google The version above

# The subcommand corresponding to the tool
$ ls -lh /usr/local/Cellar/pssh/2.3.1_1/bin/
pnuke -> ../libexec/bin/pnuke
prsync -> ../libexec/bin/prsync
pscp -> ../libexec/bin/pscp
pslurp -> ../libexec/bin/pslurp
pssh -> ../libexec/bin/pssh
pssh-askpass -> ../libexec/bin/pssh-askpass

Number

Sons command

Corresponding function explanation

1

pssh

adopt ssh The protocol runs commands in parallel on multiple hosts

2

pscp

adopt ssh The protocol copies files to multiple hosts in parallel

3

rsync

adopt rsync The protocol efficiently copies files to multiple hosts in parallel

4

slurp

adopt ssh The protocol copies files from multiple remote hosts to the central host in parallel

5

pnuke

adopt ssh The protocol kills processes on multiple remote hosts in parallel

1. pssh

adopt ssh The protocol runs commands in parallel on multiple hosts

  • Command parameters use

Number

Parameter options

Corresponding parameter explanation

1

-h HOST_FILE

Specifies the host file list file ; The content format is ”[user@]host[:port]”

2

-H HOST_STRING

Specifies the host string address ; The content format is ”[user@]host[:port]”

3

-l USER

Specify the user name to log in with

4

-p PAR

Set the number of concurrent threads ( Optional )

5

-o OUTDIR

Standard normal output file directory ( Optional )

6

-e ERRDIR

Standard error output file directory ( Optional )

7

-t TIMEOUT

Timeout settings , among 0 Means unlimited ( Optional )

8

-O OPTION

Set up SSH The option to

9

-x ARGS

Extra command line arguments use white space 、 quotes 、 Backslash processing

10

-X ARG

Extra command line arguments , Single parameter mode , Same as -x Parameters

11

-A

Manual password mode

12

-i

Each server processes information output internally

13

-P

Print out the information returned by the server

14

--help

view help , That's the message

15

--version

Show program version number

  • Applicable examples
# Usage: pssh [OPTIONS] command [...]
# Run the command on both hosts and print its output on each server
$ pssh -i -H "host1 host2" hostname -i
# Run the command and save the output to a separate file
$ pssh -H host1 -H host2 -o path/to/output_dir hostname -i
# Run the command on multiple hosts and specify... In a new line separated file
$ pssh -i -h path/to/hosts_file hostname -i
# With root Run the command ( Request input root User password )
$ pssh -i -h path/to/hosts_file -A -l root_username hostname -i
# Running with extra SSH Parameter command
$ pssh -i -h path/to/hosts_file -x "-O VisualHostKey=yes" hostname -i
# The number of running parallel connections is limited to 10 The order of
$ pssh -i -h path/to/hosts_file -p 10 'cd dir; ./script.sh; exit'

2. pscp

adopt ssh The protocol copies files to multiple hosts in parallel

  • Command parameters use

Number

Parameter options

Corresponding parameter explanation

1

-h HOST_FILE

Specifies the host file list file ; The content format is ”[user@]host[:port]”

2

-H HOST_STRING

Specifies the host string address ; The content format is ”[user@]host[:port]”

3

-l USER

Specify the user name to log in with

4

-p PAR

Set the number of concurrent threads ( Optional )

5

-o OUTDIR

Standard normal output file directory ( Optional )

6

-e ERRDIR

Standard error output file directory ( Optional )

7

-t TIMEOUT

Timeout settings , among 0 Means unlimited ( Optional )

8

-O OPTION

Set up SSH The option to

9

-x ARGS

Extra command line arguments use white space 、 quotes 、 Backslash processing

10

-X ARG

Extra command line arguments , Single parameter mode , Same as -x Parameters

11

-A

Manual password mode

12

-r

Replication directory for recursion ( Optional )

13

--help

view help , That's the message

14

--version

Show program version number

  • Applicable examples
# Usage: pscp [OPTIONS] local remote
# Copy local files to a remote machine
$ pscp -h hosts.txt -l root foo.txt /home/irb2/foo.txt
[1] 23:00:08 [SUCCESS] 172.18.10.25
[2] 09:52:28 [SUCCESS] 172.18.10.24

3. prsync

adopt rsync The protocol efficiently copies files to multiple hosts in parallel

  • Command parameters use

Number

Parameter options

Corresponding parameter explanation

1

-h HOST_FILE

Specifies the host file list file ; The content format is ”[user@]host[:port]”

2

-H HOST_STRING

Specifies the host string address ; The content format is ”[user@]host[:port]”

3

-l USER

Specify the user name to log in with

4

-p PAR

Set the number of concurrent threads ( Optional )

5

-o OUTDIR

Standard normal output file directory ( Optional )

6

-e ERRDIR

Standard error output file directory ( Optional )

7

-t TIMEOUT

Timeout settings , among 0 Means unlimited ( Optional )

8

-O OPTION

Set up SSH The option to

9

-x ARGS

Extra command line arguments use white space 、 quotes 、 Backslash processing

10

-X ARG

Extra command line arguments , Single parameter mode , Same as -x Parameters

11

-A

Manual password mode

12

-r

Replication directory for recursion ( Optional )

12

-a

Use rsync Archive Mode of ( Optional )

12

-z

Use rsync Compression mode of ( Optional

12

-S ARGS

Set up ssh Extension parameters of the protocol ( Optional )

13

--help

view help , That's the message

14

--version

Show program version number

  • Applicable examples
# Usage: prsync [OPTIONS] local remote
# Use rsync Protocol for local file replication operations
$ prsync -r -h hosts.txt -l root foo /home/irb2/foo

4. pslurp

adopt ssh The protocol copies files from multiple remote hosts to the central host in parallel

  • Command parameters use

Number

Parameter options

Corresponding parameter explanation

1

-h HOST_FILE

Specifies the host file list file ; The content format is ”[user@]host[:port]”

2

-H HOST_STRING

Specifies the host string address ; The content format is ”[user@]host[:port]”

3

-l USER

Specify the user name to log in with

4

-p PAR

Set the number of concurrent threads ( Optional )

5

-o OUTDIR

Standard normal output file directory ( Optional )

6

-e ERRDIR

Standard error output file directory ( Optional )

7

-t TIMEOUT

Timeout settings , among 0 Means unlimited ( Optional )

8

-O OPTION

Set up SSH The option to

9

-x ARGS

Extra command line arguments use white space 、 quotes 、 Backslash processing

10

-X ARG

Extra command line arguments , Single parameter mode , Same as -x Parameters

11

-A

Manual password mode

12

-r

Replication directory for recursion ( Optional )

13

-L LOCALDIR

Specify the local directory where the files are stored

14

--help

view help , That's the message

15

--version

Show program version number

  • Applicable examples
# Usage: pslurp [OPTIONS] remote local
# Copy the files on the remote host to the local
$ pslurp -h hosts.txt -l root -L /tmp/outdir /home/irb2/foo.txt foo.txt

5. pnuke

adopt ssh The protocol kills processes on multiple remote hosts in parallel

  • Command parameters use

Number

Parameter options

Corresponding parameter explanation

1

-h HOST_FILE

Specifies the host file list file ; The content format is ”[user@]host[:port]”

2

-H HOST_STRING

Specifies the host string address ; The content format is ”[user@]host[:port]”

3

-l USER

Specify the user name to log in with

4

-p PAR

Set the number of concurrent threads ( Optional )

5

-o OUTDIR

Standard normal output file directory ( Optional )

6

-e ERRDIR

Standard error output file directory ( Optional )

7

-t TIMEOUT

Timeout settings , among 0 Means unlimited ( Optional )

8

-O OPTION

Set up SSH The option to

9

-x ARGS

Extra command line arguments use white space 、 quotes 、 Backslash processing

10

-X ARG

Extra command line arguments , Single parameter mode , Same as -x Parameters

11

-A

Manual password mode

12

--help

view help , That's the message

13

--version

Show program version number

  • Applicable examples
# Usage: pnuke [OPTIONS] pattern
# End the process task on the remote host
$ pnuke -h hosts.txt -l root java

Reprinted from :「 Escape The blog of 」, original text :https://tinyurl.com/y2zucscu, The copyright belongs to the original author . Welcome to contribute , Send email : editor@hi-linux.com.

This article is from WeChat official account. - Beauty of operation and maintenance (Hi-Linux) , author :Escape

The source and reprint of the original text are detailed in the text , If there is any infringement , Please contact the yunjia_community@tencent.com Delete .

Original publication time : 2021-03-31

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[iMike]所创,转载请带上原文链接,感谢
https://javamana.com/2021/04/20210416162503881j.html

  1. K8s命令篇-Kubernetes工作实用命令集结号
  2. K8s command chapter - kubernetes working practical command collection number
  3. San Wai doesn't even know how to change MySQL table DDL
  4. HTTP series - detailed explanation of message structure
  5. MySQL 存储引擎 MyISAM 与 InnoDB 区别
  6. The difference between MySQL storage engine MyISAM and InnoDB
  7. 《算法竞赛入门经典——训练指南》实用数据结构
  8. Practical data structure of "Introduction to algorithm competition classic training guide"
  9. Hive的数据压缩介绍及使用
  10. Introduction and use of hive's data compression
  11. Please put away this database interview summary for spring recruitment
  12. Redis:23---info命令总结
  13. Redis:23---info Command summary
  14. Quick start kubernetes (k8s) - resource list
  15. What's in HTTP header?
  16. Linux commands 4-find, locate
  17. linuxNote1_ user management
  18. Brief description of Tencent cloud redis console parameters
  19. Redis transaction management
  20. Regular expression in Java
  21. Linux text processing
  22. Don't download JDK any more: elasticsearch's first big hole in the domestic arm environment
  23. Getting started with spring boot 2. X: getting started with spring MVC request mapping (@ requestmapping)
  24. Introduction to MySQL architecture
  25. Linux foundation day02
  26. [javap6 outline] Spring Court: how to select the technology of fuse framework? Sentinel or hystrix?
  27. Top of BPF: insight into Linux system and application performance
  28. Various parameter configuration of docker
  29. JQuery level selector (descendant, descendant selector)
  30. Interesting JavaScript - precision loss and implicit type conversion
  31. Database: built in functions of MySQL