Skip to content
ecdsa.com
OpenSSH (ssh-keygen, ssh-add, ssh)SSH

Error message

Load key "/path/to/key": incorrect passphrase supplied to decrypt private key

Also printed as

  • incorrect passphrase supplied to decrypt private key
  • Bad passphrase, try again for /path/to/key:

Interactive `ssh-add` asks again with "Bad passphrase, try again for …:"; `ssh` itself just prompts again.

OpenSSH (ssh-keygen, ssh-add, ssh) — encrypted private key

What it means

The key file parsed fine and is encrypted; decrypting it with the passphrase you supplied failed. OpenSSH can tell this apart from a damaged file because the encrypted container includes a check value — so this message really means "wrong passphrase", for OpenSSH-format keys and for encrypted PEM/PKCS#8 keys alike. There is no way to recover a forgotten passphrase; the key has to be replaced.

Why it happens

How to fix it

  1. 1.

    Test the passphrase interactively

    If `ssh-keygen -y` accepts the passphrase you type, the problem is in how your script supplies it.

    bash
    ssh-keygen -y -f ~/.ssh/id_ed25519 > /dev/null   # prompts; succeeds only with the right passphrase
    ssh-keygen -p -f ~/.ssh/id_ed25519                # change the passphrase (needs the old one)
  2. 2.

    Use an agent instead of passing passphrases

    Unlock the key once in `ssh-agent` (or the OS keychain) rather than embedding the passphrase in scripts or CI.

    bash
    # Unlock once per session instead of typing or storing the passphrase in scripts
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519
    # macOS: keep it in the keychain
    ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Related errors

Browse the full signature error database