This question already has an answer here:
- Are GPG and SSH keys interchangable? 3 answers
Last year I created an 4096 bit RSA key pair with GPG / Enigmail in Thunderbird. Enigmail lists me a primary key used to sign and authenticate e-mails, and a subkey used to encrypt e-mails. I exported the key pair to an .asc file.
Now I wanted to use these keys for a SSH connection and exported the keys like this:
gpg2 --armor --export-secret-keys [key] > sec_key.txt ssh-add sec_key.txt
When ssh-add asks me for a passphrase, I enter the right one (that works in Enigmail) but it is rejected:
Bad passphrase, try again
Using the public key (exported with --export) leads to the same error, as well as using the subkey. "ssh -v -i sec_key.txt localhost" gives this error:
key_parse_private_pem: PEM_read_PrivateKey failed
But the passphrase must be correct because I'm able to change the passphrase with GPG:
gpg --edit-key [key]
I also tried to remove the passphrase completely but then I cannot log into ssh. "ssh-add sec_key.txt" then gives no output but returns 1.
What can I do to use this keys for ssh connections?