| Crates.io | sshconfig |
| lib.rs | sshconfig |
| version | 0.1.0 |
| created_at | 2025-05-20 02:34:57.858012+00 |
| updated_at | 2025-05-20 02:34:57.858012+00 |
| description | A library for parsing SSH config files in Rust. |
| homepage | |
| repository | https://github.com/poneding/sshconfig |
| max_upload_size | |
| id | 1680677 |
| size | 29,723 |
A Rust library for parsing SSH config files into a structured format in Rust.
Add sshconfig crate to your cargo project:
cargo add sshconfig
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(())
}
Each HostEntry object represents a Host entry in the SSH config file and contains:
name: The host alias namehost: The actual hostname or IP addressport: The port number (default: 22)user: The username (default: "root")identity_file: The identity file path (default: "~/.ssh/id_rsa")This project is licensed under the MIT or Apache-2.0 license.