Why does SSH report an invalid private-key format?
The selected identity may not be an OpenSSH-readable private key. Common causes include selecting the .pub file, choosing a PuTTY-format key, or damaging the file during copying. Validate the file privately before changing anything on the server.
Instructions
1. Confirm the identity filename
The -i argument normally points to the private file without .pub. Check its path and size without displaying its contents.
Get-Item -LiteralPath "$env:USERPROFILE\.ssh\server_ed25519" | Select-Object FullName, LengthA zero-length or unexpected file size can indicate the wrong or incomplete file. Size alone does not validate a key.
2. Ask OpenSSH to read the private key
This derives the public key but discards the output. Enter a passphrase only at the interactive prompt.
ssh-keygen -y -f "$env:USERPROFILE\.ssh\server_ed25519" | Out-Null
$LASTEXITCODEA successful read returns zero. The command does not print the private key.
3. Use the correct authorised format
If the original key belongs to another application, use that application’s official export procedure. Do not paste private material into online conversion tools. If the file is corrupted and cannot be recovered, generate and enrol a new identity using an existing authorised access path.
Check the result
- OpenSSH can read the intended private key without format errors.
- Its public fingerprint matches the key enrolled on the server.
Troubleshooting
- The file is a .ppk key
- Use the official PuTTY key conversion workflow if that is the genuine source format.
- A passphrase is rejected
- Confirm the correct key and passphrase; formatting changes cannot recover an unknown passphrase.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
