Skip to main content

KeyService

Struct KeyService 

Source
pub struct KeyService<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> KeyService<'a>

Source

pub fn new(paths: &'a SshPaths, runner: &'a dyn CliRunner) -> Self

Source

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.

Source

pub async fn create(&self, params: KeyCreateParams) -> Result<SshKey>

Generate a new SSH key pair.

§Errors

Error::InvalidKeyName (bad name), Error::ToolNotFound, Error::CommandFailed.

Source

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.

Source

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.

Source

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.

Source

pub async fn chmod_fix(&self, key_name: &str) -> Result<()>

Fix key file permissions (private 0o600, public 0o644).

§Errors

Error::KeyNotFound, Error::InvalidKeyName, or Error::Io.

Source

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).

Source

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

Error::KeyNotFound or Error::CommandFailed.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for KeyService<'a>

§

impl<'a> !UnwindSafe for KeyService<'a>

§

impl<'a> Freeze for KeyService<'a>

§

impl<'a> Send for KeyService<'a>

§

impl<'a> Sync for KeyService<'a>

§

impl<'a> Unpin for KeyService<'a>

§

impl<'a> UnsafeUnpin for KeyService<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more