Parallel SSH in Python

I wonder how best to handle concurrent SSH connections in python. I need to open several SSH connections in order to maintain the background and issue commands interactively or temporarily. Can this be done using paramiko libraries? It would be nice not to create another SSH process for each connection.

Thanks.

+3
source share
6 answers

It might be worth checking which options are available in Twisted. For example, on the Twisted.Conch page:

http://twistedmatrix.com/users/z3p/files/conch-talk.html

OpenSSH, Conch . Twisted .

+3

, paramiko.

, . , . , .

, , , . , , . , , , .

+3

subprocess.Popen - .

cronjob .: -)

+1

API paramiko, , ssh- ssh- . ssh- (openssh) , .

+1

clusterssh, . , .

pssh, .

, , - dsh:

 Description: dancer shell, or distributed shell
 Executes specified command on a group of computers using remote shell
 methods such as rsh or ssh.
 .
 dsh can parallelise job submission using several algorithms, such as using
 fan-out method or opening as much connections as possible, or
 using a window of connections at one time.
 It also supports "interactive mode" for interactive maintenance of
 remote hosts.
 .
 This tool is handy for administration of PC clusters, and multiple hosts.
 

: - . node .

http://www.netfort.gr.jp/~dancer/software/dsh.html

+1
source

This does not apply to your question. But there are tools like pssh, clusterssh, etc. that can create connections in parallel. You can bind Expect to pssh to manage them.

-1
source

Source: https://habr.com/ru/post/1713600/


All Articles