-
Notifications
You must be signed in to change notification settings - Fork 345
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 ProxyCommand support #153
Comments
@sergzin - are you asking if the library supports using SSH-tunneling through a jumphost; i.e. a security hardended box? If so, that functionality is supported and I can provide details. If you are looking for something else, could you please include a URL to the functionality of ProxyCommand you are inquiring about? Thank you! |
yes, Thank you. |
I can't get nested proxycommand to work. In my SSH config,
ERROR:ncclient.transport.ssh:Exception: Error reading SSH protocol banner with _read_timeout() in https://github.com/Juniper/py-junos-eznc/blob/master/lib/jnpr/junos/device.py I am not seeing anything loading proxycommand at all |
To make things worse, the docs on the Juniper website are also inaccurate.
If it helps the maintainers, then this feature is available in Netmiko which builds on Paramiko. ProxyJump can also be used on Paramiko. It would be really nice to have a fix for this one. I've read the blog post which asks the user to setup port forwarding and then run a shell command to open up a tunnel prior to running the program/script. This is counterinituitive. If SSH can support proxying, and the library can interpret SSH config files then it should be able to honour what's in the file. |
@dhanakane Will work and get this closed by next week. |
It is working for me (please note it doesn't mean it is working for everybody):
$ python
Python 3.6.10 (default, Mar 9 2020, 12:07:57)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from jnpr.junos import Device
>>> dev = Device(host="mx480", user="qwe",password="asd", ssh_config="~/.ssh/config-lab", port=22)
>>> dev.open()
Device(mx480)
>>> dev.close() ProxyCommand is loaded by ncclient here: You can verify if it is working in the debug logs: >>> import logging
>>> logging.basicConfig(level=0)
>>> dev.open()
DEBUG:ncclient.transport.session:[host None session 0x7f72bc098828] <SSHSession(session, initial daemon)> created: client_capabilities=<dict_keyiterator object at 0x7f72bbea1868>
DEBUG:ncclient.transport.ssh:[host mx480 session 0x7f72bc098828] Configuring Proxy. ssh -W mx480:22 -q lab
... Or try to mimic the same thing manually: >>> import paramiko
>>> import os
>>> ssh_config = open(os.path.expanduser("~/.ssh/config-lab"))
>>> config = paramiko.SSHConfig()
>>> config.parse(ssh_config)
>>> config=config.lookup("mx480")
>>> config.get("proxycommand")
'ssh -W mx480:22 -q lab'
>>> Please note that I am using keys to authenticate to the jumphost and the keys are load into agent, which can be confirmed by |
@dhanakane the error you see "Error reading SSH protocol banner" in this case is because hostname/ip resolution of the end device on the jumphost fails. Try adding the host entry to /etc/hosts on the jumphost and remove the Hostname param from your ssh config for the device that requires the jumphost. This should resolve it in the interim. |
If we have config like this
PyEZ will overwrite Host with Hostname here: py-junos-eznc/lib/jnpr/junos/device.py Line 431 in 6f02b26
It is then passed to ncclient as host. As result ncclient will be trying to get config for wrong Host and fail to get ProxyCommand. |
@a-v-popov do you mean that token expansion breaks? When I debug with a known working SSH config file using In my case, I'm currently working around this using local portforwarding with wrapped subprocess calls to turn up and turn down the tunnel. Super hacky, but I have no choice until there's a fix that honours my SSH config file. @jalphonso that was not the error I was referring to, but thanks for chiming in. I learned something else there. |
You don't need to resolve it locally. It should be resolvable on the jumphost.
|
To establish connection via intermedate security hardened box.
The text was updated successfully, but these errors were encountered: