I've lost my key. Now I can't sign anything, and servers don't accept unsigned content. The key is uploaded to a keyserver. Now I have fingerprint, public key and I remember my passphrase.

How can I re-generate same key on my Linux box?

  • 2
    If the private key could be generated from the public key (not counting brute force), what use would public key cryptography be?
    – Mat
    Sep 22, 2012 at 16:18
  • 1
    @Mat I remember passphrase! I have everything needed to make a key, though newly generated keys have different fingerpring and ID. And server don't accept signed content with new keys (same passphrase, algorithm,...)
    – sorush-r
    Sep 22, 2012 at 16:38
  • The passphrase is used to protect your private key on disk. It's not related to the private key itself.
    – Mat
    Sep 22, 2012 at 16:39
  • Oh... Do I need to know generated prime numbers to make same key?
    – sorush-r
    Sep 22, 2012 at 16:41
  • 4
    Well, sort of. If you know the primes (or whatever the secret is for the crypto algorithm you're using is), you have your key already (just not in the right format). If you don't know the secret, you cannot generate it from the public part, unless you brute-force it, or the algorithm is bad, or you happen to be unlucky enough to have used one of the algo's weak keys (if that exists).
    – Mat
    Sep 22, 2012 at 16:43

1 Answer 1


You cannot generate the private key¹ from the public key and the passphrase. The private key does not depend on the passphrase in any way. The passphrase is only used to encrypt the private key when you store it in a file. You could have multiple copies of the same private key encrypted with different passphrases. And you cannot recover the private key from the public key, public key cryptography relies on this being impossible.

The only way to recover your private key is from a backup of the private key.

¹ Outside of gpg, it's typically called a private key when there's a corresponding public key, and a secret key for symmetric encryption.

  • gnupg does not seem to share your worldview on the nomenclature of secret and private keys; gnupg uses flags like --list-secret-keys, --export-secret-keys, etc., which are used to refer to what you call private keys. What I'm trying to say is that there does not appear to be a single objectively correct way of calling things, many people will use the two terms interchangeably, and trying to be clever by correcting people when they use another term that the one you like does not help much, particularly when it is clear from the context what it means.
    – koniiiik
    May 26, 2016 at 11:45
  • 1
    @koniiiik Gpg is rather the exception. The point of my footnote was precisely to warn readers that this is unusual terminology. May 26, 2016 at 12:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .