Skip to content

A user-friendly SSH client wrapper for Rust, designed with a focus on ergonomics and safety.

License

Notifications You must be signed in to change notification settings

DarkLichCode/easy-ssh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀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.

✨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(())
}

⌨️Examples

⚠️ This example uses a public demo server (test.rebex.net) with demo credentials. Do not use it for real workloads.

cargo run --example password

⚠️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

About

A user-friendly SSH client wrapper for Rust, designed with a focus on ergonomics and safety.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages