Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting public key from GnuPG fails with "WARNING: nothing exported"

Tags:

gnupg

openpgp

pgp

Im new to PGP and I'm trying to generate a PGP private key using GnuPG through this tutorial.

Basically, I have type the following command in command prompt (in administrator mode):

  1. gpg --gen-key
  2. Entered all the commands as below: enter image description here

  3. Then I entered the command:

    gpg --armor --output pubkey.txt --export 'Encryption purpose'
    

but get a

WARNING: nothing exported

message.

Can someone tell me what I'm doing wrong?

Also, I will be using PGP to encrypt a webapp download file. I'm planning to create a web application that will generate a file with random numbers that would need be encrypted (in PGP). Then to decrypt, I'm planning to create a stand alone application that will decrypt the file using the private key. So my question is:

  1. Is it possible to extract the private key from the original computer in which the private key was generated to be used with other computers so that other computers could also use the standalone application to decrypt the file using the private key from the original computer?

  2. If this is not possible, how do I share the private key for all computers with the decrypting standalone application (because as I understand, standalone application needs 'a' private key to decrypt the file)? Should I use multiple private keys? How to implement?

like image 410
AshT Avatar asked Sep 09 '15 09:09

AshT


People also ask

What is GnuPG public key?

GnuPG uses public-key cryptography so that users may communicate securely. In a public-key system, each user has a pair of keys consisting of a private key and a public key. A user's private key is kept secret; it need never be revealed. The public key may be given to anyone with whom the user wants to communicate.

Where are GnuPG keys stored?

All secret keys are stored in the 'private-keys-v1. d' directory below the GnuPG home directory. So, those *. key files are the actual, current-version secret keys, also known as private keys.


2 Answers

You've got the --export command wrong. It does not take an export purpose as parameter, but a key or user ID. From man gpg:

--export
    Either export all keys from all keyrings (default keyrings and  those  regis‐
    tered  via  option --keyring), or if at least one name is given, those of the
    given name. The exported keys are written to STDOUT or to the file given with
    option --output.  Use together with --armor to mail those keys.

To export the private key, run --export-secret-keys instead. Public keys cannot be used to decrypt files, only for encryption and verification of signatures.

like image 128
Jens Erat Avatar answered Sep 22 '22 06:09

Jens Erat


This error is caused by the --export parameter not matching any of the user ids (usually email addresses) listed in gpg --list-keys.

The solution is to run:

  1. gpg --gen-key

Make a note of the email you use to generate the key (eg [email protected]). Then plug that into gpg:

  1. gpg --armor --output mypublic.key --export '[email protected]'

Also in Ubuntu it seems gpg2 is now preferred, so use eg gpg2 --gen-key.

like image 29
nik Avatar answered Sep 23 '22 06:09

nik