jdx/mise · error
no public key for the SSH private key at
Error message
no public key for the SSH private key at {}; expected {} What it means
When building age encryption recipients from an SSH private key, agecrypt looks for the corresponding .pub file next to it. If the public key file is missing or its content does not start with 'ssh-' (so it is not a valid OpenSSH public key), it throws this error since the public key is required to derive the recipient.
Solutions
- Generate the missing public key: run `ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub`
- Ensure the .pub file sits next to the private key with the expected name (private path + '.pub')
- Verify the .pub file content starts with 'ssh-' (e.g. 'ssh-ed25519 AAAA...'); fix or regenerate it if not
- Alternatively pass the public key explicitly via a supported recipient option instead of relying on derivation from the private key
Example fix
// before (missing sibling pub key)
let recipient = load_ssh_recipient_from_path("~/.ssh/id_ed25519")?;
// after: regenerate the pub key first
// $ ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub
let recipient = load_ssh_recipient_from_path("~/.ssh/id_ed25519")?; Defensive patterns
Strategy: validation
Validate before calling
let pub_path = path.with_extension("pub"); // or path + ".pub" per convention
if !pub_path.exists() {
return Err(anyhow!("missing public key {}; run ssh-keygen -y -f {} > {}", pub_path.display(), path.display(), pub_path.display()));
} Type guard
fn has_ssh_pub_key(priv_path: &Path) -> bool {
priv_path
.parent()
.and_then(|d| std::fs::read_to_string(d.join(priv_path.file_name()?).to_string_lossy() + ".pub").ok())
.map(|c| c.trim().starts_with("ssh-"))
.unwrap_or(false)
} Try / catch
match load_ssh_recipient_from_path(&key_path) {
Ok(r) => use_recipient(r),
Err(e) if e.to_string().contains("no public key") => regenerate_pub_key(&key_path)?,
Err(e) => return Err(e),
} Prevention
- Always keep private keys and their .pub siblings together; never delete just the .pub file
- Regenerate the .pub with `ssh-keygen -y` after key rotation
- Validate the .pub starts with 'ssh-' before relying on it
- Prefer explicit recipient strings when the key layout is nonstandard
When it happens
Trigger: Calling default_recipient_strings or load_ssh_recipient_from_path with a private key path (e.g. ~/.ssh/id_ed25519) whose sibling .pub file does not exist, or whose .pub file contains unexpected/non-OpenSSH content.
Common situations: User deleted or regenerated the key pair without keeping the .pub file; key stored with a nonstandard layout; .pub file holds a certificate or a comment-only line; pointing at a PuTTY or PEM-format key that has no ssh-* sibling.
Related errors
- a repository preview directory requires a dry run
- brew-cask: binary artifact
- brew-cask: binary artifact
- brew-cask: completion artifact
- brew-cask: structured copy source
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/1b68a360e479c375.
Report an issue: GitHub.
Appendix: source
Thrown at src/agecrypt.rs:298
.map_err(|e| eyre!("age recipient plugin is unavailable: {e}"))?;
Ok(Some(Box::new(plugin)))
} else {
Ok(None)
}
}
/// The public key beside an SSH private key: age cannot derive it, so the
/// `.pub` file must exist.
pub(crate) async fn ssh_public_key_for_private(path: &Path) -> Result<String> {
let pub_path = path.with_extension("pub");
if pub_path.exists() {
let content = file::read_to_string(&pub_path)?;
let trimmed = content.trim();
if trimmed.starts_with("ssh-") {
return Ok(trimmed.to_string());
}
}
bail!(
"no public key for the SSH private key at {}; expected {}",
display_path(path),
display_path(&pub_path)
)
}
/// Every identity this machine has: `MISE_AGE_KEY`, the identity files
/// named by the settings and the default `age.txt`, and the SSH keys named
/// by the settings and the default `~/.ssh/id_ed25519` / `id_rsa`.
pub(crate) async fn load_all_identities() -> LoadedIdentities {
load_identities(false).await
}
async fn load_identities(interactive: bool) -> LoadedIdentities {
let identity_files = get_all_identity_files().await;
let ssh_identity_files = get_all_ssh_identity_files();
let mut loaded = LoadedIdentities::default();
let mut plugin_sources = Vec::new();View on GitHub (pinned to 533346cc37)