sshconfig

Crates.iosshconfig
lib.rssshconfig
version0.1.0
created_at2025-05-20 02:34:57.858012+00
updated_at2025-05-20 02:34:57.858012+00
descriptionA library for parsing SSH config files in Rust.
homepage
repositoryhttps://github.com/poneding/sshconfig
max_upload_size
id1680677
size29,723
Pone Ding (poneding)

documentation

https://github.com/poneding/sshconfig

README

sshconfig

A Rust library for parsing SSH config files into a structured format in Rust.

Installation

Add sshconfig crate to your cargo project:

cargo add sshconfig

Usage

Basic Usage

use sshconfig::parse_ssh_config;
use std::io;

fn main() -> io::Result<()> {
    // Parse an SSH config file
    let entries = parse_ssh_config("./examples/parse-ssh-config/example_config")?;

    // Process the entries
    for entry in entries {
        println!("name: {}", entry.name);
        println!("host: {}", entry.host);
        println!("user: {}", entry.user);
        println!("port: {}", entry.port.unwrap_or(22));
        println!(
            "identity file: {}",
            entry.identity_file.unwrap_or("~/.ssh/id_rsa".to_string())
        );
    }

    Ok(())
}

HostEntry Structure

Each HostEntry object represents a Host entry in the SSH config file and contains:

  • name: The host alias name
  • host: The actual hostname or IP address
  • port: The port number (default: 22)
  • user: The username (default: "root")
  • identity_file: The identity file path (default: "~/.ssh/id_rsa")

License

This project is licensed under the MIT or Apache-2.0 license.

Commit count: 5

cargo fmt