ecdsa.com
OpenSSHOther tools

Error message

Load key "/path/to/key": invalid format

The path is filled in per invocation. Related wording from the same loader: "unknown or unsupported key type" for corrupted body bytes (both reproduced with OpenSSH on macOS), and "error in libcrypto" on some versions for PEM-level failures.

OpenSSH — ssh, ssh-keygen, ssh-add

What it means

OpenSSH tried to load a private key file and could not parse it in any format it knows (OPENSSH PRIVATE KEY, PKCS#8, legacy PEM). The file is damaged, truncated, in a foreign format like PuTTY's .ppk, or is not a private key at all — this is a file-format failure, before any passphrase or server interaction.

Why it happens

How to fix it

  1. 1.

    Inspect the framing first

    The first and last lines plus a validity probe (-y prints the public key if — and only if — the private key parses) identify the failure class in seconds.

    bash
    head -1 ~/.ssh/id_ecdsa      # -----BEGIN OPENSSH PRIVATE KEY-----
    tail -c 50 ~/.ssh/id_ecdsa | xxd | tail -1   # must end with 0a (newline)
    ssh-keygen -y -f ~/.ssh/id_ecdsa             # parses? prints the public key
  2. 2.

    Convert PuTTY keys to OpenSSH format

    One-time conversion with puttygen; afterwards the key works with ssh, ssh-add and ssh-agent.

    bash
    puttygen key.ppk -O private-openssh -o ~/.ssh/id_converted
    chmod 600 ~/.ssh/id_converted
  3. 3.

    Transfer keys losslessly

    Move key files with scp/rsync rather than clipboards, keep permissions at 600, and if the private key is unrecoverable, generate a fresh pair — modern OpenSSH favors Ed25519.

    bash
    scp -p old-host:~/.ssh/id_ecdsa ~/.ssh/
    # or start clean:
    ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519

Related errors

← Browse the full signature error database