easy-ssh: A high-level, builder-pattern SSH client wrapper

⚓ Rust    📅 2026-02-07    👤 surdeus    👁️ 1      

surdeus

:rocket:easy-ssh

Crates.io License

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.

:sparkles:Features

  • :hammer_and_wrench:Fluent API : Use SSHBuilder to easily configure connections.
  • :key: Smart Auth : Supports password authentication and public key (PEM/RSA) authentication.
  • :shield: 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.
  • :magnifying_glass_tilted_left: Clear Errors : Provide actionable error prompts with repair suggestions based on thiserror.

:package: Installation

This is a synchronous (blocking) library. For async support, stay tuned for our Roadmap

Cargo.toml

[dependencies]
easy-ssh = "0.1"

:keyboard: 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(())
}

:warning: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

:world_map:Roadmap

:white_check_mark: Password Authentication

:white_check_mark: Public Key Authentication

:white_check_mark: Execute shell command

:white_large_square: Async backend (tokio + openssh)

:white_large_square: Interactive shell support

:white_large_square: SFTP Support

:white_large_square: Connection pooling

:scroll:License

MIT LICENSE

1 post - 1 participant

Read full topic

🏷️ Rust_feed