Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Working through jumphost #288

murbaker started this conversation in General
Mar 30, 2021 · 2 comments · 2 replies
Discussion options

I have my .ssh/config file configured to allow simple ssh through jump hosts to servers within a protected zone. This allows a command like "ssh fred+10.10.10.10" to take me directly through the jump host to the destination machine. (I don't really understand how this works as I'm not a SSH guru.) This doesn't work through the parallel-ssh library. Is there some other way to make this work? I'm testing this with the sample code just with my jump host address.

Sample SSH config entry:

Host fred
Hostname jumphost-fred

Host fred+*
ControlMaster auto
ProxyCommand ssh -T -a $(echo %h |cut -d+ -f1) nc $(echo %h |cut -d+ -f2) %p 2>/dev/null
ControlPath ~/.ssh/ssh-control_%r@%h:%p
StrictHostKeyChecking no

Test code:

from pssh.clients import ParallelSSHClient
hosts = ['fred+10.14.16.14', 'fred+10.18.19.10']
client = ParallelSSHClient(hosts)
output = client.run_command('uname -a;hostname')
for host_output in output:
 for line in host_output.stdout:
 print(line)
 exit_code = host_output.exit_code
 print(exit_code)

Output:

Traceback (most recent call last):
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 272, in _connect
self.sock.connect((host, port))
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 602, in connect
address = _resolve_addr(self._sock, address)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 444, in _resolve_addr
r = getaddrinfo(host, None, sock.family)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 247, in getaddrinfo
addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/resolver/thread.py", line 63, in getaddrinfo
return self.pool.apply(_socket.getaddrinfo, args, kwargs)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/pool.py", line 161, in apply
return self.spawn(func, *args, **kwds).get()
File "src/gevent/event.py", line 329, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 359, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 347, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 327, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/threadpool.py", line 167, in __run_task
thread_result.set(func(*args, **kwargs))
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 272, in _connect
self.sock.connect((host, port))
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 602, in connect
address = _resolve_addr(self._sock, address)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 444, in _resolve_addr
r = getaddrinfo(host, None, sock.family)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 247, in getaddrinfo
addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/resolver/thread.py", line 63, in getaddrinfo
return self.pool.apply(_socket.getaddrinfo, args, kwargs)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/pool.py", line 161, in apply
return self.spawn(func, *args, **kwds).get()
File "src/gevent/event.py", line 329, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 359, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 347, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 327, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/threadpool.py", line 167, in __run_task
thread_result.set(func(*args, **kwargs))
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 272, in _connect
self.sock.connect((host, port))
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 602, in connect
address = _resolve_addr(self._sock, address)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 444, in _resolve_addr
r = getaddrinfo(host, None, sock.family)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_socketcommon.py", line 247, in getaddrinfo
addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/resolver/thread.py", line 63, in getaddrinfo
return self.pool.apply(_socket.getaddrinfo, args, kwargs)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/pool.py", line 161, in apply
return self.spawn(func, *args, **kwds).get()
File "src/gevent/event.py", line 329, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 359, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 347, in gevent._gevent_cevent.AsyncResult.get
File "src/gevent/event.py", line 327, in gevent._gevent_cevent.AsyncResult._raise_exception
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/threadpool.py", line 167, in __run_task
thread_result.set(func(*args, **kwargs))
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 6, in
output = client.run_command('uname -a;hostname')
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/native/parallel.py", line 217, in run_command
return_list=return_list, read_timeout=read_timeout if read_timeout else timeout,
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/parallel.py", line 198, in run_command
return_list=return_list)
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/parallel.py", line 204, in _get_output_from_cmds
finished = joinall(_cmds, raise_error=True)
File "src/gevent/greenlet.py", line 1057, in gevent._gevent_cgreenlet.joinall
File "src/gevent/greenlet.py", line 1073, in gevent._gevent_cgreenlet.joinall
File "src/gevent/greenlet.py", line 371, in gevent._gevent_cgreenlet.Greenlet._raise_exception
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/parallel.py", line 216, in _get_output_from_greenlet
raise ex
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/parallel.py", line 209, in _get_output_from_greenlet
host_out = cmd.get()
File "src/gevent/greenlet.py", line 803, in gevent._gevent_cgreenlet.Greenlet.get
File "src/gevent/greenlet.py", line 371, in gevent._gevent_cgreenlet.Greenlet._raise_exception
File "/home/mbaker/.local/lib/python3.7/site-packages/gevent/_compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/parallel.py", line 285, in _run_command
raise ex
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/parallel.py", line 277, in _run_command
_client = self._make_ssh_client(host_i, host)
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/native/parallel.py", line 252, in _make_ssh_client
identity_auth=self.identity_auth,
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/native/single.py", line 129, in init
identity_auth=identity_auth)
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 195, in init
self._init()
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 198, in _init
self._connect(self._host, self._port)
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 278, in _connect
return self._connect(host, port, retries=retries+1)
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 278, in _connect
return self._connect(host, port, retries=retries+1)
File "/home/mbaker/.local/lib/python3.7/site-packages/pssh/clients/base/single.py", line 284, in _connect
raise ex
pssh.exceptions.UnknownHostError: ('Unknown host %s - %s - retry %s/%s', 'fred+10.14.16.14', 'Name or service not known', 3, 3)

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

See documentation on using proxies.

client = ParallelSSHClient(hosts, proxy_host='jumphost')

You must be logged in to vote
2 replies
Comment options

Thanks for that, I guess I should have equated proxy with jump host.

I've still not got it working but I think that's more likely related to our unusual environment than any direct issue with parallel-ssh.

Comment options

There are options for providing proxy user name, key file and etc where proxy auth differs from target host, see documentation.

OpenSSH configs are not read by parallel-ssh.

Comment options

Thanks for that. I haven't had time to work with those settings but I'm sure I'll get it to work. From: Panos ***@***.***> Sent: Thursday, April 1, 2021 19:49 To: ParallelSSH/parallel-ssh ***@***.***> Cc: Murray Baker ***@***.***>; Author ***@***.***> Subject: Re: [ParallelSSH/parallel-ssh] Working through jumphost (#288) There are options for providing proxy user name, key file and etc where proxy auth differs from target host, see documentation. OpenSSH configs are not read by parallel-ssh. - You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FParallelSSH%2Fparallel-ssh%2Fdiscussions%2F288%23discussioncomment-556680&data=04%7C01%7Cmurray.baker%40blackboard.com%7Ceb3a0237abce42de36e508d8f4ef2dff%7Cbf0b29a25e5c4aaaba4dac988df15ea6%7C0%7C0%7C637528655399930634%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Ywq3Gtd2xLLZg2odHcWxes0zMA8wIz8qIg0RppgdEoE%3D&reserved=0>, or unsubscribe<https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FATOTGC22ASSPIZ7Y34K4TLLTGQ3ADANCNFSM42BFK2RQ&data=04%7C01%7Cmurray.baker%40blackboard.com%7Ceb3a0237abce42de36e508d8f4ef2dff%7Cbf0b29a25e5c4aaaba4dac988df15ea6%7C0%7C0%7C637528655399940629%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=MwTfs6dPXmlyGSWwsm2PpD%2BBFe4uMckoWVX40JGQba8%3D&reserved=0>. This email and any attachments may contain confidential and proprietary information of Blackboard that is for the sole use of the intended recipient. If you are not the intended recipient, disclosure, copying, re-distribution or other use of any of this information is strictly prohibited. Please immediately notify the sender and delete this transmission if you received this email in error.
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /