Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have lost the GPG keys I use for Launchpad and email encryption, along with my entire ~/.gnupg folder. Can I recover them using the public key?

share|improve this question
    
The secret key is secret for a reason. No, you cannot generate a new one and make it identical, as then someone will be able to generate your secret key. –  hexafraction Sep 22 '12 at 19:12
    
@ObsessiveFOSS It's my key and I'm the only one who knows the secret key (I assume that's why it's called a secret key). I also remember decryption/encryption algorithms, email and the comment used in key. Now, having the public key, am I able to regenerate secret key or not? –  sorush-r Sep 22 '12 at 19:24
    
@andrewsomething No. The questioner you mentioned, have the key available on one machine. but I've lost my key. (The computer exploded) –  sorush-r Sep 22 '12 at 19:26
1  
Do not close this question. It is not a duplicate, as the OP has lost his keys. Anyway, this would be a good canonical question about key loss. –  hexafraction Sep 22 '12 at 19:39
    
I edited this to be more canonical. Do you mind the edits? –  hexafraction Oct 5 '12 at 0:21
show 1 more comment

3 Answers 3

up vote 8 down vote accepted

@andrewsomething No. The questioner you mentioned[sic], have[sic] the key available on one machine. but I've lost my key. (The computer exploded)

Sorry, but you cannot get your key back. This is by design.

The RSA (and DSA/ElGamal) algorithms are engineered so that the keys must be made at the same time. There are intermediate variables that are not stored as part of the either the private or public key. Because the public key is crafted to be made public, you cannot deduce the secret key from it, or there would be a giant security hole. The two primes are generated from random numbers.

Also, the key email/name/description have no bearing on the modulus("meaty" data portion of the key). Therefore, you cannot recover your secret key without a backup, at least not without factoring large numbers which cannot be easily done right now. The passphrase is used to protect the key with another (symmetric) key generated from the passphrase, but neither this key nor the password affect the modulus in any way except a stray source of random data.

What can I do?

You can go to Launchpad key management after logging in via username and password, revoke your old keys. and then make and publish new keys. There is no limit on the number of keys you can publish. Make a secure backup, and ensure nobody gets unauthorized access to the backup, and that the keys in the backup are protected by a passphrase.

share|improve this answer
add comment

No, it is highly unprobable that you'd be able to generate the same key again.

However, you can easily import/export keys following the steps below:

Importing the keyring (all the keys)

Just copy the ~/.gnupg directory from the source machine to the destination machine.

Importing only a particular key

Suppose the name of the key is ABCDFE01.

Export the public and private keys to files named mygpgkey_pub.gpg and mygpgkey_sec.gpg respectively.

gpg --output mygpgkey_pub.gpg --armor --export ABCDFE01
gpg --output mygpgkey_sec.gpg --armor --export-secret-key ABCDFE01 

Then, copy those files to the destination computer, and run:

gpg --import ~/mygpgkey_pub.gpg
gpg --allow-secret-key-import --import ~/mygpgkey_sec.gpg 

Source: http://www.ralree.com/2007/03/07/howto-export-and-import-private-gpg-keys/

share|improve this answer
    
Yes, that's why it has "NO" as the first word. The remaining process only applies to "import/export keys". –  green7 Sep 22 '12 at 21:14
add comment

Open your unity dash and type as seahorse it will list you passwords and applications. click it to open . there your created keys will exist at My personal keys Tab. select that.There you can see your created key . select that key , then automatically in the menu export option will active and select that export button . then save it your desired location .

Now open your destination system where you would like to import this . There also as mentioned above same process upto opening passwords and application . In that application from main menu choose file and select Import . through you can choose the key which you have saved from your 1st PC .

Look at the images if you want more clarity . enter image description here enter image description here enter image description here enter image description here

share|improve this answer
    
I've lost my key (whole ~/.gnugpg directory). I remember passphrase and details, but newly generated keys have different fingerprints and public keys... For that reason, Launchpad don't accept my signatures. –  sorush-r Sep 22 '12 at 16:14
1  
This answer doesn't apply to the OP as he/she has lost her keys fully. –  hexafraction Sep 22 '12 at 19:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.