NII-cloud-operation / sshkernel

SSH Kernel for Jupyter
BSD 3-Clause "New" or "Revised" License
71 stars 14 forks source link

Is it difficult to support ProxyCommand? #17

Closed iranika closed 4 years ago

iranika commented 4 years ago

This kernel is verry good. Thanks : ) By the way, I want to using ProxyCommand param for ssh tunneling.

e.g.

Host ServerA
  Hostname ServerA
  User iranika
  IdentityFile ~/.ssh/iranika.id_rsa
  ProxyCommand ssh gateway -W %h:%p
Host gateway
  Hostname gateway
  User iranika
  IdentityFile ~/.ssh/iranika.id_rsa

But, sshkernel not support ProxyCommand. Is'nt it?

I found sample code , used paramiko. https://gist.github.com/tell-k/4943359

I think sshkernel will possible supporting ProxyCommand. But, Is it difficult or No Good?

If I write code at python, it takes many time. So, Please tell me it is defficult or easy. or add support PorxyCommand param : )

hi-uni commented 4 years ago

It's easy if you just want to use the proxy command. Change https://github.com/NII-cloud-operation/sshkernel/blob/297faa720daf9f54a0a26884efdc5cadce92ead0/sshkernel/ssh_wrapper_plumbum.py#L80 to remote = ParamikoMachine (hostname, password = None, load_system_ssh_config=True, **plumbum_kwargs).

m-ueno commented 4 years ago

Thanks! I'll check it.

m-ueno commented 4 years ago

ProxyCommand is supported partially at version 0.10.0. Please check the current limitation in https://github.com/NII-cloud-operation/sshkernel/pull/22 and feel free to open new issues. Thank you anyway.

toddkaufmann commented 2 years ago

I think paramiko already supports ProxyCommand, but complains about hostname also being there.
After thinking about this, I realized hostname being here is redundant; I commented it out and it worked fine.
Can you try:

Host ServerA
  # Hostname ServerA
  User iranika
  IdentityFile ~/.ssh/iranika.id_rsa
  ProxyCommand ssh gateway -W %h:%p

This assumes the gateway knows the host (either by name resolution, or .ssh/config on gateway);
if not explicit substitution in %h is another possible workaround without changing code.