Crates.io | ssh_jumper |
lib.rs | ssh_jumper |
version | 0.4.0 |
source | src |
created_at | 2021-03-13 09:17:57.723598 |
updated_at | 2021-09-05 01:32:53.63802 |
description | Async SSH tunnel through a jump host. |
homepage | |
repository | https://github.com/azriel91/ssh_jumper |
max_upload_size | |
id | 368237 |
size | 46,072 |
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`.
Licensed under either of
at your option.
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.