add proxy support
ipmsteven opened this issue · 4 comments
Hi @rubencaro
I come from ruby world where its ssh library support the proxy feature like here
https://net-ssh.github.io/ssh/v2/api/classes/Net/SSH/Proxy/Command.html
I checked the erlang ssh doc and it seems that there is no proxy support?
Correct me if I am wrong
Nice idea!
Maybe something like that could be supported using EEx
itself with the given command to run/3
like this:
{:ok, res, 0} = SSHEx.run conn, "ls /path/composed_by/<%= host %>/and/<%= port %>", use_eex: true
It looks simple enough. SSHEx
itself would execute internally something like:
final_command = EEx.eval_string given_command, [host: actual_host, port: actual_port]
Look at it as if you were using Ruby's Erb
to render given command as a template (but faster!).
What data is given to EEx to be replaced can be a growing list over time (i.e. no need to be limited to host
and port
). Whenever someone needs a new one, just needs to add it and it will work.
Maybe there can be some switch on opts
to enable this feature (a simple :use_eex
would do), just to avoid extra work, as this is usually not needed. No harm is done.
If this would do it for you, then it does not look too hard to code. Maybe you can do it yourself. Pull requests are welcome!
I will do it if I find time, but that's hard to see lately.
EDIT: I see it would be faster to use function_from_string/5
. See here.
hmm, maybe I didn't explain my question very clearly.
The feature that I need is a proxy support like http://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/
I have a server A
which has a public IP and a server B
which is in a private a network, to ssh to B
I have to go through server A
.
In my ssh config file, I specify a rule to use A
as a proxy:
Host B
ProxyCommand ssh A -W %h:%p 2>/dev/null
I am wondering if I could do the similar thing in SSHEx?
Haha, I'm sorry. I'm the one that did not understand your question!
Here I see that it looks like it's not supported by underlying Erlang ssh
, as it says explicitly that supports RFC4251:
(...)
Except (...) 9.5.2 Proxy Forwarding
(...)
But it's not too clear, and I'm just a mere user of :ssh
, as SSHEx
is just a collection of helpers to make it easier from Elixir. You should ask this yourself on the Erlang mailing list here. There lay the actual masters. Ask about 'SSH Support for Proxy Forwarding' and they will give you something.
If you get the Erlang code that does it, then maybe I can help you add a helper to SSHEx
to make it easier to use from Elixir.
Thanks!
Thanks @rubencaro 👍