libssh-rs icon indicating copy to clipboard operation
libssh-rs copied to clipboard

Question: How do I create a hopped ssh session via a tunnel?

Open SnoCold opened this issue 1 year ago • 0 comments

Hi, I was going through the code and found this method

pub fn [open_forward](https://docs.rs/libssh-rs/latest/libssh_rs/struct.Channel.html#method.open_forward)(
    &self,
    remote_host: &[str](https://doc.rust-lang.org/nightly/std/primitive.str.html),
    remote_port: [u16](https://doc.rust-lang.org/nightly/std/primitive.u16.html),
    source_host: &[str](https://doc.rust-lang.org/nightly/std/primitive.str.html),
    source_port: [u16](https://doc.rust-lang.org/nightly/std/primitive.u16.html)
) -> [SshResult](https://docs.rs/libssh-rs/latest/libssh_rs/type.SshResult.html)<[()](https://doc.rust-lang.org/nightly/std/primitive.unit.html)>

I am interested in creating an ssh tunnel via a bastion host to remote server e.g. ssh -l localhost:1234:192.168.1.1:22 root@bastion

where 192.168.1.1 is the remote server with username root

and then creating a session as such

ssh localhost -p 1234 -l root

How would I achieve this using this library? and how would I authenticate ? assuming initial session to bastion is established.

Please do let me know.

Thank you, Regards,

SnoCold avatar Aug 26 '24 22:08 SnoCold