Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH Multiplexing #347

Closed
chikkujimmy opened this issue Jul 15, 2022 · 1 comment
Closed

SSH Multiplexing #347

chikkujimmy opened this issue Jul 15, 2022 · 1 comment
Labels

Comments

@chikkujimmy
Copy link

chikkujimmy commented Jul 15, 2022

I tried using SSH multiplexing (to speed up remote login procedure) by creating a config file in the path ~/.ssh/config with the below content

Host anyhostname (you can give any hostname)
HostName (Host IP address)
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p.socket
ControlPersist 30m

and when I try to call this in the parallel SSH script

from pssh.clients import ParallelSSHClient

host = ['anyhostname']
cmd = 'uptime'
client = ParallelSSHClient(host, user='root', password='password')
#client = ParallelSSHClient(host, user='root')
#client = ParallelSSHClient(host, pkey='~/.ssh/config')
output = client.run_command(cmd)
for host_out in output:
    for line in host_out.stdout:
        print(line)

it is giving an error pssh.exceptions.UnknownHostError: ('Unknown host %s - %s - retry %s/%s', 'anyhostname', 'Temporary failure in name resolution', 3, 3).

But when I try the command line I am able to connect via Parallel SSH

$ parallel-ssh -i -l user1 -o StrictHostKeyChecking=no -h ~/pssh-hosts uptime
[1] 16:19:49 [SUCCESS] local-250
16:19:49 up 13:55, 2 users, load average: 23.52, 35.55, 51.63

How can I specify the multiplexing hostnames or implement multiplexing in your parellel SSH script? As per your documentation there are options for password and private key accesses which are working fine

@pkittenis
Copy link
Member

pkittenis commented Jul 31, 2022

Hi there,

Thanks for the interest.

The quickstart documentation describes how to use ParallelSSHClient. This project does not read ~/.ssh/config, nor does it support an SSH config as argument to pkey.

from pssh.clients import ParallelSSHClient

hosts = ['localhost', 'localhost', 'localhost', 'localhost']
client = ParallelSSHClient(hosts)
cmd = 'uname'

output = client.run_command(cmd)
for host_out in output:
    for line in host_out.stdout:
        print(line)

Multiplexing is not supported nor needed for this library. Simply keep the client object in scope to reuse the same connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants