Crates.io | openssh-keys |
lib.rs | openssh-keys |
version | 0.6.4 |
source | src |
created_at | 2017-09-02 01:42:47.178599 |
updated_at | 2024-07-12 14:48:17.594696 |
description | read and write OpenSSH public keys |
homepage | https://github.com/coreos/openssh-keys |
repository | https://github.com/coreos/openssh-keys |
max_upload_size | |
id | 30209 |
size | 77,012 |
A pure-Rust library to handle OpenSSH public keys.
openssh-keys
can parse, print, and fingerprint OpenSSH public keys.
It supports the following algorithms:
It can construct RSA and DSA keys from their components using the PublicKey::from_rsa()
and
PublicKey::from_dsa()
functions respectively.
extern crate openssh_keys;
use std::{env, fs, io, path};
use std::io::BufRead;
fn main() {
let home = env::home_dir().unwrap_or(path::PathBuf::from("/home/core/"));
let pub_path = home.join(".ssh").join("id_rsa.pub");
println!("Inspecting '{}':", pub_path.to_string_lossy());
let file = fs::File::open(&pub_path).expect("unable to open RSA pubkey");
let reader = io::BufReader::new(file);
for (i, line) in reader.lines().enumerate() {
let line = line.expect(&format!("unable to read key at line {}", i + 1));
let pubkey = openssh_keys::PublicKey::parse(&line).expect("unable to parse RSA pubkey");
println!(" * Pubkey #{} -> {}", i + 1, pubkey.to_fingerprint_string());
}
}
Some more examples are available under examples.
Releases can be performed by creating a new release ticket and following the steps in the checklist there.
Licensed under either of
at your option.
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.