Extract an SSH Private Key Hash with ssh2john
credentialstool
Summary
Converts a passphrase-protected SSH private key into a John-compatible hash so the passphrase can be cracked with john/hashcat.
Walkthrough
When you recover a private key (e.g. id_ed25519) that is passphrase-protected, convert it to a crackable hash with ssh2john, then feed that hash to John the Ripper or hashcat with a wordlist.
Steps
- Convert the key to a John-format hash and save it to a file:
``bash ssh2john id_ed25519 > hash.txt ``
- Confirm the hash was written:
``bash cat hash.txt ``
- Crack
hash.txtwith John/hashcat and a wordlist to recover the passphrase, then use it tossh -i id_ed25519.
Commands
bash
ssh2john id_ed25519 > hash.txt
bash
cat hash.txt