Expand description
§SSH Manager
A comprehensive Rust library for executing SSH commands programmatically.
§Features
- Simple and intuitive API for SSH connections
- Execute remote commands with ease
- Flexible authentication (password, public key)
- Comprehensive error handling
- Well-documented with examples
§Quick Start
use lmrc_ssh::{SshClient, AuthMethod};
// Connect with password authentication
let mut client = SshClient::new("example.com", 22)?
.with_auth(AuthMethod::Password {
username: "user".to_string(),
password: "pass".to_string(),
})
.connect()?;
// Execute a command
let output = client.execute("ls -la")?;
println!("Output: {}", output.stdout);§Examples
§Password Authentication
use lmrc_ssh::{SshClient, AuthMethod};
let mut client = SshClient::new("192.168.1.100", 22)?
.with_auth(AuthMethod::Password {
username: "admin".to_string(),
password: "secret".to_string(),
})
.connect()?;
let result = client.execute("whoami")?;
println!("Current user: {}", result.stdout);§Public Key Authentication
use lmrc_ssh::{SshClient, AuthMethod};
let mut client = SshClient::new("example.com", 22)?
.with_auth(AuthMethod::PublicKey {
username: "user".to_string(),
private_key_path: "/home/user/.ssh/id_rsa".to_string(),
passphrase: None,
})
.connect()?;
let result = client.execute("hostname")?;
println!("Hostname: {}", result.stdout);Structs§
- Command
Output - The output of an executed SSH command.
- SshClient
- An SSH client for executing remote commands.
Enums§
- Auth
Method - Authentication methods for SSH connections.
- Error
- Error types that can occur during SSH operations.
Type Aliases§
- Result
- Result type alias for SSH operations.