← Back to search

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

  1. Convert the key to a John-format hash and save it to a file:

``bash ssh2john id_ed25519 > hash.txt ``

  1. Confirm the hash was written:

``bash cat hash.txt ``

  1. Crack hash.txt with John/hashcat and a wordlist to recover the passphrase, then use it to ssh -i id_ed25519.

Commands

bash

ssh2john id_ed25519 > hash.txt

bash

cat hash.txt