pub struct DotSsh { /* private fields */ }
std
only.Expand description
~/.ssh
directory support (or similarly structured directories).
Implementations§
Source§impl DotSsh
impl DotSsh
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Open ~/.ssh
if the home directory can be located.
Returns None
if the home directory couldn’t be located.
Sourcepub fn open(path: impl Into<PathBuf>) -> Self
pub fn open(path: impl Into<PathBuf>) -> Self
Open a ~/.ssh
-structured directory.
Does not verify that the directory exists or has the right file permissions.
Attempts to canonicalize the path once opened.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Get the path to the ~/.ssh
directory (or whatever DotSsh::open
was called with).
Sourcepub fn config_path(&self) -> PathBuf
pub fn config_path(&self) -> PathBuf
Get the path to the ~/.ssh/config
configuration file. Does not check if it exists.
Sourcepub fn private_keys(&self) -> Result<impl Iterator<Item = PrivateKey>>
pub fn private_keys(&self) -> Result<impl Iterator<Item = PrivateKey>>
Iterate over the private keys in the ~/.ssh
directory.
Sourcepub fn private_key_with_fingerprint(
&self,
fingerprint: Fingerprint,
) -> Option<PrivateKey>
pub fn private_key_with_fingerprint( &self, fingerprint: Fingerprint, ) -> Option<PrivateKey>
Find a private key whose public key has the given key fingerprint.
Sourcepub fn public_keys(&self) -> Result<impl Iterator<Item = PublicKey>>
pub fn public_keys(&self) -> Result<impl Iterator<Item = PublicKey>>
Iterate over the public keys in the ~/.ssh
directory.
Sourcepub fn public_key_with_fingerprint(
&self,
fingerprint: Fingerprint,
) -> Option<PublicKey>
pub fn public_key_with_fingerprint( &self, fingerprint: Fingerprint, ) -> Option<PublicKey>
Find a public key with the given key fingerprint.
Sourcepub fn write_private_key(
&self,
filename: impl AsRef<Path>,
key: &PrivateKey,
) -> Result<()>
pub fn write_private_key( &self, filename: impl AsRef<Path>, key: &PrivateKey, ) -> Result<()>
Write a private key into ~/.ssh
.
Trait Implementations§
Source§impl Default for DotSsh
impl Default for DotSsh
Source§fn default() -> Self
fn default() -> Self
Calls DotSsh::new
and panics if the home directory could not be located.