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:
Lorenz Leutgeb
2026-08-23 19:28:32 +02:00
parent 31f3d08d63
commit d66f7e598b
2 changed files with 10 additions and 6 deletions
+8 -4
View File
@@ -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(())
}
+2 -2
View File
@@ -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,
},
})
}