#tunnel #ssh #async

ssh_jumper

Async SSH tunnel through a jump host

5 releases (3 breaking)

0.4.0 Sep 5, 2021
0.3.0 Sep 2, 2021
0.2.0 Jun 12, 2021
0.1.1 Mar 25, 2021
0.1.0 Mar 13, 2021

#53 in #tunnel

Download history 10/week @ 2024-06-26 22/week @ 2024-07-03 21/week @ 2024-07-10 4/week @ 2024-07-17 14/week @ 2024-07-24 12/week @ 2024-07-31 16/week @ 2024-08-07 60/week @ 2024-08-14 36/week @ 2024-08-21 4/week @ 2024-09-04 11/week @ 2024-09-11 9/week @ 2024-09-18 29/week @ 2024-09-25 15/week @ 2024-10-02 19/week @ 2024-10-09

82 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

30KB
478 lines

🌐💨 SSH Jumper

Crates.io docs.rs CI Coverage Status

Async SSH tunnel through a jump host.

use std::borrow::Cow;
use ssh_jumper::{
    model::{HostAddress, HostSocketParams, JumpHostAuthParams, SshTunnelParams},
    SshJumper
};

// Similar to running:
// ssh -i ~/.ssh/id_rsa -L 1234:target_host:8080 my_user@bastion.com
let (local_socket_addr, ssh_forwarder_end_rx) = {
    let jump_host = HostAddress::HostName(Cow::Borrowed("bastion.com"));
    let jump_host_auth_params = JumpHostAuthParams::new(
        Cow::Borrowed("my_user"),
        Cow::Borrowed(Path::new("~/.ssh/id_rsa")),
    );
    let target_socket = HostSocketParams {
        address: HostAddress::HostName(Cow::Borrowed("target_host")),
        port: 8080,
    };
    let ssh_params =
        SshTunnelParams::new(jump_host, jump_host_auth_params, target_socket)
            // Optional: OS will allocate a port if this is left out
            .with_local_port(1234);

    SshJumper::open_tunnel(&ssh_params).await?
};

// Now you can send traffic to `local_socket_addr`, and it will go to `target_host`.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~15–30MB
~439K SLoC