[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ssh connection via a proxy


On 03/08/2021 08:52, Andreas Schneider wrote:
> On Monday, August 2, 2021 11:28:10 PM CEST Jeremy Fix wrote:
>> Hello,
> Hi,
>
>> I would like to use libssh for connecting to a remote host via a
>> gateway, executing a command on the remote host and parsing its standard
>> outputs/errors; So the picture is  localhost -> gateway -> remote
>>
>> I'm pretty new with libssh. I used to do that with command line ssh by
>> specifying 
>>
>>     ssh -o ProxyCommand='ssh -W %h:%p mylogin@gateway' mylogin@remote
>> mycommand
>>
>> It is not obvious to me how to do that with libssh; One track I have in
>> mind is a variant of the above with :
>>
>>     ssh -L 9999:remote:22 mylogin@gateway
>>
>>     ssh -p 9999 mylogin@localhost mycommand
>>
>> therefore I would establish a tunnel then create a new libssh session on
>> localhost and execute the command in a channel on this new session.
> Which part to do you want to implement with libssh exactly. The client side or 
> the proxy or both?

I think I need to implement the whole chain. To specify the constraints;
I need my program to run on Linux/Windows/MacOS and I thought, but I may
be wrong, that I need to handle everything related to ssh with libssh.

>
> libssh supports the proxy command see the options:
> https://api.libssh.org/stable/
> group__libssh__session.html#ga7a801b85800baa3f4e16f5b47db0a73d
>
> SSH_OPTIONS_PROXYCOMMAND: Set the command to be executed in order to connect 
> to server (const char *).

I agree but what puzzles me is that my proxy command "ProxyCommand='ssh
-W %h:%p mylogin@gateway'" does involve ssh which I should also handle
with libssh I believe.  If I want my program to be cross platform,
shouldn't I also code the  'ssh -W %h:%p mylogin@gateway' with libssh ? 

>
> 	Andreas
>


Follow-Ups:
Re: ssh connection via a proxyAndreas Schneider <asn@xxxxxxxxxxxxxx>
References:
ssh connection via a proxyJeremy Fix <Jeremy.Fix@xxxxxxxxxxxxxxxxxx>
Re: ssh connection via a proxyAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org