mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-18 19:10:30 +08:00
cli, crypto: Comment keys in SSH Agent
To avoid confusion how the key ended up in SSH Agent, add a comment that adds some explanation. See also <https://radicle.zulipchat.com/#narrow/channel/392584-Feedback/topic/ssh-key.20with.20comment.20in.20agent/with/618208959>.
This commit is contained in:
@@ -184,8 +184,9 @@ pub fn register(
|
||||
profile: &Profile,
|
||||
passphrase: crypto::ssh::Passphrase,
|
||||
) -> anyhow::Result<()> {
|
||||
let secret = profile
|
||||
.keystore
|
||||
let keystore = &profile.keystore;
|
||||
let secret_key_path = keystore.secret_key_path();
|
||||
let secret = keystore
|
||||
.secret_key(Some(passphrase))
|
||||
.map_err(|e| {
|
||||
if e.is_crypto_err() {
|
||||
@@ -194,9 +195,12 @@ pub fn register(
|
||||
e.into()
|
||||
}
|
||||
})?
|
||||
.ok_or_else(|| anyhow!("Key not found in {:?}", profile.keystore.secret_key_path()))?;
|
||||
.ok_or_else(|| anyhow!("Key not found in '{}'", secret_key_path.display()))?;
|
||||
|
||||
agent.register(&secret)?;
|
||||
agent.register(
|
||||
&secret,
|
||||
format!("Radicle key loaded from '{}'.", secret_key_path.display()),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ impl Agent {
|
||||
}
|
||||
|
||||
/// Register a key with the agent.
|
||||
pub fn register(&mut self, key: &SigningKey) -> Result<(), AgentError> {
|
||||
pub fn register(&mut self, key: &SigningKey, comment: String) -> Result<(), AgentError> {
|
||||
use ssh_key::private::{Ed25519Keypair, KeypairData};
|
||||
self.client.add_identity(proto::AddIdentity {
|
||||
credential: PrivateCredential::Key {
|
||||
@@ -103,7 +103,7 @@ impl Agent {
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
comment: "".into(),
|
||||
comment,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user