Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azriel91/ssh_cfg
Parses `~/.ssh/config` asynchronously.
https://github.com/azriel91/ssh_cfg
Last synced: 3 months ago
JSON representation
Parses `~/.ssh/config` asynchronously.
- Host: GitHub
- URL: https://github.com/azriel91/ssh_cfg
- Owner: azriel91
- License: apache-2.0
- Created: 2021-03-13T01:38:31.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-30T04:04:19.000Z (almost 2 years ago)
- Last Synced: 2024-09-16T12:29:56.969Z (3 months ago)
- Language: Rust
- Size: 130 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 🌐 SSH Cfg
[![Crates.io](https://img.shields.io/crates/v/ssh_cfg.svg)](https://crates.io/crates/ssh_cfg)
[![docs.rs](https://img.shields.io/docsrs/ssh_cfg)](https://docs.rs/ssh_cfg)
[![CI](https://github.com/azriel91/ssh_cfg/workflows/CI/badge.svg)](https://github.com/azriel91/ssh_cfg/actions/workflows/ci.yml)Parses `~/.ssh/config` asynchronously.
```rust
use ssh_cfg::{SshConfigParser, SshOptionKey};
use tokio::runtime;async fn parse_ssh_config() -> Result<(), Box> {
let ssh_config = SshConfigParser::parse_home().await?;// Print first host config
if let Some((first_host, host_config)) = ssh_config.iter().next() {
println!("Host: {}", first_host);// Print its configured SSH key if any
if let Some(identity_file) = host_config.get(&SshOptionKey::IdentityFile) {
println!(" {} {}", SshOptionKey::IdentityFile, identity_file);
}
}// Print all host configs
println!();
println!("{:#?}", ssh_config);Ok(())
}fn main() -> Result<(), Box> {
let rt = runtime::Builder::new_current_thread().build()?;
rt.block_on(parse_ssh_config())
}
```Currently values are stored as `String`s. Ideally we would parse them into a
strong data model.## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.