pub struct KeyService<'a> { /* private fields */ }Implementations§
Source§impl<'a> KeyService<'a>
impl<'a> KeyService<'a>
pub fn new(paths: &'a SshPaths, runner: &'a dyn CliRunner) -> Self
Sourcepub async fn list(&self) -> Result<Vec<SshKey>>
pub async fn list(&self) -> Result<Vec<SshKey>>
List all SSH keys on disk and in the agent; unparseable keys are skipped.
§Errors
Error::TaskFailed if the background scan task panics or is cancelled.
Sourcepub async fn create(&self, params: KeyCreateParams) -> Result<SshKey>
pub async fn create(&self, params: KeyCreateParams) -> Result<SshKey>
Generate a new SSH key pair.
§Errors
Error::InvalidKeyName (bad name), Error::ToolNotFound, Error::CommandFailed.
Sourcepub async fn delete(&self, params: KeyDeleteParams) -> Result<()>
pub async fn delete(&self, params: KeyDeleteParams) -> Result<()>
Delete a key and optionally its companions, agent entry, and config refs.
§Errors
Error::KeyNotFound, Error::InvalidKeyName, Error::Io, Error::TaskFailed, Error::ConfigWriteFailed.
Sourcepub async fn repair_public(
&self,
private_key_path: &Path,
passphrase: Option<&str>,
) -> Result<()>
pub async fn repair_public( &self, private_key_path: &Path, passphrase: Option<&str>, ) -> Result<()>
Derive the .pub from a private key (encrypted keys via ssh-keygen -y).
§Errors
Error::KeyNotFound, Error::ToolNotFound, or Error::CommandFailed.
Sourcepub async fn rename(&self, old_name: &str, new_name: &str) -> Result<()>
pub async fn rename(&self, old_name: &str, new_name: &str) -> Result<()>
Rename a key pair and companions; config refs NOT updated; companion failures non-fatal.
§Errors
Error::KeyNotFound, Error::KeyExists, Error::InvalidKeyName, Error::Io.
Sourcepub async fn chmod_fix(&self, key_name: &str) -> Result<()>
pub async fn chmod_fix(&self, key_name: &str) -> Result<()>
Fix key file permissions (private 0o600, public 0o644).
§Errors
Sourcepub async fn change_passphrase(
&self,
key_path: &Path,
old_passphrase: Option<&str>,
new_passphrase: Option<&str>,
) -> Result<()>
pub async fn change_passphrase( &self, key_path: &Path, old_passphrase: Option<&str>, new_passphrase: Option<&str>, ) -> Result<()>
Change a key’s passphrase (None/empty new removes it) via SSH_ASKPASS, never argv.
§Errors
Error::KeyNotFound or Error::CommandFailed (e.g. wrong old passphrase).
Sourcepub async fn change_comment(
&self,
key_path: &Path,
new_comment: &str,
passphrase: Option<&str>,
) -> Result<()>
pub async fn change_comment( &self, key_path: &Path, new_comment: &str, passphrase: Option<&str>, ) -> Result<()>
Change a key’s comment (ssh-keygen -c); a passphrase goes via SSH_ASKPASS, never argv.
§Errors
Sourcepub async fn convert(
&self,
key_path: &Path,
target_format: KeyFormat,
) -> Result<String>
pub async fn convert( &self, key_path: &Path, target_format: KeyFormat, ) -> Result<String>
Convert a key between OpenSSH and PEM formats, returning the content.
§Errors
Error::KeyNotFound, Error::ToolNotFound, or Error::CommandFailed.
Sourcepub async fn install_key_to_remote(
&self,
key_path: &Path,
dest: &str,
) -> Result<InstallOutcome>
pub async fn install_key_to_remote( &self, key_path: &Path, dest: &str, ) -> Result<InstallOutcome>
Install a public key to a remote’s authorized_keys via ssh-copy-id (or plain SSH).
§Errors
Error::ToolNotFound, Error::CommandFailed, or Error::KeyNotFound.
Sourcepub async fn uninstall_key_from_remote(
&self,
key_path: &Path,
dest: &str,
) -> Result<UninstallOutcome>
pub async fn uninstall_key_from_remote( &self, key_path: &Path, dest: &str, ) -> Result<UninstallOutcome>
Remove a public key from a remote host’s authorized_keys.
§Errors
Error::KeyNotFound, Error::ToolNotFound, or Error::CommandFailed.