use std::path::PathBuf;
use tracing::debug;
const SSH_KEY_NAMES: &[&str] = &["id_ed25519", "id_ecdsa", "id_rsa"];
pub fn discover_ssh_key() -> Option<PathBuf> {
let ssh_dir = dirs::home_dir()?.join(".ssh");
if !ssh_dir.exists() {
return None;
}
for key_name in SSH_KEY_NAMES {
let key_path = ssh_dir.join(key_name);
if key_path.exists() {
debug!("Found SSH key: {}", key_path.display());
return Some(key_path);
}
}
None
}
pub fn public_key_for(private_key: &std::path::Path) -> Option<PathBuf> {
let pub_path = private_key.with_extension("pub");
if pub_path.exists() {
Some(pub_path)
} else {
None
}
}