easy-ssh: A high-level, builder-pattern SSH client wrapper
⚓ Rust 📅 2026-02-07 👤 surdeus 👁️ 1
easy-ssh
A small, opinionated SSH client library built on top of ssh2.
This crate focuses on:
- Explicit configuration
- Clear error reporting
- Minimal abstractions over ssh2
- Non-interactive SSH use cases (exec-first)
It is designed as a building block for system tools, automation, and future async integrations.
Features
Fluent API : Use SSHBuilder to easily configure connections.
Smart Auth : Supports password authentication and public key (PEM/RSA) authentication.
Fail-Fast Validation : Pre-verify the private key format before connection to avoid obscure errors caused by libssh2's lack of support for the OpenSSH format.
Clear Errors : Provide actionable error prompts with repair suggestions based on thiserror.
Installation
This is a synchronous (blocking) library. For async support, stay tuned for our Roadmap
Cargo.toml
[dependencies]
easy-ssh = "0.1"
Quick Start
Password Authentication
use easy_ssh::{SSHBuilder, AuthMethod};
fn main() -> Result<(), Box<dyn std::error::Error>>{
let ssh = SSHBuilder::new("host")
.auth(AuthMethod::Password {
username : "username".into(),
password : "password".into(),
})
.connect()?;
println!("{}", ssh.exec("ls -la")?);
let (result, status) = ssh.exec_with_status("whoami")?;
println!("{} {}", status, result);
Ok(())
}
Public Key Authentication
use easy_ssh::{SSHBuilder, AuthMethod};
fn main() -> Result<(), Box<dyn std::error::Error>>{
let ssh = SSHBuilder::new("host")
.auth(AuthMethod::Key {
username : "username".into(),
private_key : "private_key full path".into(),
passphrase : None,
})
.connect()?;
println!("{}", ssh.exec("ls -la")?);
let (result, status) = ssh.exec_with_status("whoami")?;
println!("{} {}", status, result);
Ok(())
}
Private Key Format
This library uses libssh2, which does not support OpenSSH private key format.
Generate a compatible key using:
ssh-keygen -t rsa -b 4096 -m PEM
Roadmap
Password Authentication
Public Key Authentication
Execute shell command
Async backend (tokio + openssh)
Interactive shell support
SFTP Support
Connection pooling
License
MIT LICENSE
1 post - 1 participant
🏷️ Rust_feed