Features Examples Docs GitHub
Async SSH library for Rust

SSH made simple.

A lightweight, asynchronous Rust library for SSH operations. Execute remote commands, transfer files via SCP, and manage interactive PTY sessions with an ergonomic builder API. Built on tokio and russh.

Get Started View Examples
src examples basic.rs
1use simple_ssh::Session;
2use anyhow::Result;
3
4// Execute remote commands with the builder API
5async fn main() -> Result<()> {
6 let session = Session::init()
7 .with_host("192.168.1.100")
8 .with_user("admin")
9 .with_passwd("secret")
10 .with_port(2222)
11 .build()?;
12
13 let mut ssh = session.connect().await?;
14
15 // Run a command and get exit code
16 let code = ssh.cmd("uname -a").await?;
17 println!("Exit code: {}", code);
18
19 Ok(())
20}
master* Rust
Ln 7, Col 9 UTF-8 LF
src examples scp.rs
1use simple_ssh::Session;
2use anyhow::Result;
3
4// Transfer files securely via SCP
5async fn main() -> Result<()> {
6 let session = Session::init()
7 .with_host("server.example.com")
8 .with_user("deploy")
9 .with_key("~/.ssh/id_rsa".into())
10 .build()?;
11
12 let mut ssh = session.connect().await?;
13
14 // Upload local file to remote
15 ssh.scp("./target/release/app", "/usr/local/bin/app").await?;
16
17 Ok(())
18}
master* Rust
Ln 12, Col 5 UTF-8 LF
src examples pty.rs
1use simple_ssh::Session;
2use anyhow::Result;
3
4// Interactive PTY session with raw mode
5async fn main() -> Result<()> {
6 let session = Session::init()
7 .with_host("server.local")
8 .with_user("admin")
9 .with_key("~/.ssh/id_ed25519".into())
10 .build()?;
11
12 let mut ssh = session.connect().await?;
13
14 // Interactive shell with raw mode and auto-resize
15 let exit_code = ssh
16 .pty_builder()
17 .with_raw()
18 .with_term("xterm-256color")
19 .with_auto_resize()
20 .run()
21 .await?;
22
23 Ok(())
24}
master* Rust
Ln 16, Col 9 UTF-8 LF
src examples ipv6.rs
1use simple_ssh::Session;
2use anyhow::Result;
3
4// Connect to IPv6 link-local address with scope ID
5async fn main() -> Result<()> {
6 let session = Session::init()
7 .with_host("fe80::1")
8 .with_scope("eth0") // Network interface
9 .with_user("pi")
10 .with_passwd("raspberry")
11 .build()?;
12
13 let mut ssh = session.connect().await?;
14
15 Ok(())
16}
master* Rust
Ln 8, Col 19 UTF-8 LF

Everything you need for SSH in Rust.

A complete toolkit for SSH operations with an ergonomic builder API designed for async Rust.

Async by Design

Built on tokio and russh for truly non-blocking SSH operations. Execute multiple commands concurrently without blocking your runtime.

SCP File Transfers

Upload and download files securely with the same async API. Minimal code, maximum reliability for your file transfer needs.

Interactive PTY

Full terminal sessions with raw mode support, auto-resize, and mode detection for alt-buffer apps like vim and nano.

IPv6 Link-Local

Full IPv6 support including link-local addresses with scope ID. Connect to devices on your local network without DNS configuration.

Flexible Auth

Password, key-based, certificate, and no-auth methods. simple_ssh automatically selects the right authentication based on your configuration.

CLI Tools Included

Ready-to-use simple-ssh and simple-scp binaries. Terminal multiplexer support with 1x2, 2x1, and 2x2 layouts for managing multiple sessions.

Copy, paste, run.

Practical examples for common SSH operations.

Cargo.toml
# Add to your Cargo.toml
[dependencies]
simple_ssh = { git = "https://github.com/juliankahlert/simple_ssh" }
tokio = { version = "1", features = ["full"] }
anyhow = "1"
Programmatic PTY for TUIs
// Embed SSH in your TUI application
let mut handle = ssh
    .pty_builder()
    .with_term("xterm-256color")
    .with_size(80, 24)
    .open()
    .await?;

// Send input programmatically
handle.write(b"ls -la\n").await?;

// Read output
while let Some(data) = handle.read().await {
    println!("Received: {:?}", data);
}

Add it to your project.

Install via Cargo or use the pre-built CLI tools.

$ cargo add simple_ssh