1

I want to generate GnuPG public private key pairs. I have gpg and not gpg2 installed.So I went to terminal and did:

gpg --gen-key

output:

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)

I selected 1 Output:

What keysize do you want? (2048) 

I selected 4096 Output:

Key is valid for? (0)

I selected 0 Output:

You need a user ID to identify your key; 
the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Name Title (some comment) <samplename@example.com>"

Real name: My Name
Email address: example@email.com
Comment: comment
You selected this USER-ID:
"My Name (comment) <example@email.com>"

Output:

You need a Passphrase to protect your secret key.

I gave passphrase Output:

gpg: key XXXXXXXL marked as ultimately trusted
public and secret key created and signed.

pub   ABCDE/XXXXXXXL 2016-06-09
Key fingerprint = XXXX XXXX XXXX XXXX XXXX  XXXX XXXX XXXX XXXX XXXXL
uid                  My Name (comment) <example@email.com>
sub   ABCDE/XXXXXXXM 2016-06-09

I added the following line to my ~/.profile:

export GPGKEY=XXXXXXXM

Then to source it I did

killall -q gpg-agent
eval $(gpg-agent --daemon)
export GPGKEY=XXXXXXXM

Next I encrypted it:

gpg --cert-digest-algo=SHA256 --edit-key XXXXXXXM

Output:

Secret key is available.

pub   ABCDE/XXXXXXXM  created: 2016-06-09  expires: never       usage: SC  
                     trust: ultimate      validity: ultimate
[ultimate] (1). My Name (comment) <example@email.com>

Command> 

I did

addkey

Output:

Please select what kind of key you want:
   (2) DSA (sign only)
   (4) Elgamal (encrypt only)
   (5) RSA (sign only)
   (6) RSA (encrypt only)

I selected 6 Output:

What keysize do you want? (2048)

I selected 4096 Output:

Key is valid for? (0)

I selected 0 Output:

pub   ABCDE/XXXXXXXL  created: 2016-06-09  expires: never       usage: SC  
                     trust: ultimate      validity: ultimate
sub   ABCDE/XXXXXXXM created: 2016-06-09  expires: never       
sub   ABCDE/XXXXXXXN created: 2016-06-09  expires: never       usage: E   

[ultimate] (1). My Name (comment) <example@email.com>
Command> 

I did:

save

Next I did:

gpg --list-keys

This is my sample output:

pub   ABCDE/XXXXXXXL 2016-06-09
uid                  My Name (comment) <example@email.com>
sub   ABCDE/XXXXXXXM 2016-06-09
sub   ABCDE/XXXXXXXN 2016-06-10

However when I do

`gpg --list-secret-keys`

I get de-to-de the same output with the exception of sec in place of pub:

sec   ABCDE/XXXXXXXL 2016-06-09
uid                  My Name (comment) <example@email.com>
sub   ABCDE/XXXXXXXM 2016-06-09
sub   ABCDE/XXXXXXXN 2016-06-10

I know that the portion after pub ABCDE/ is the public key and the portion after sec ABCDE/ is the private key. So in short, my public key and private key are the same.

Another peculiar scenario is that here three lines start with ABCDE, but the combination has to be different.

How can I get separate public and private keys?

  • Are you using gpg version 1 or 2? – Stefano Palazzo Jun 10 '16 at 15:25
  • @Videonauth I have again updated my question – rancho Jun 10 '16 at 17:51
1

I know that the portion after pub ABCDE/ is the public key and the portion after sec ABCDE/ is the private key.

You're mistaking the algorithm identification field with the key ID.

sec   ABCDE/XXXXXXXL 2016-06-09
uid                  My Name (comment) <example@email.com>
sub   ABCDE/XXXXXXXM 2016-06-09
sub   ABCDE/XXXXXXXN 2016-06-10

The field you've been hiding through ABCDE can never be ABCDE. This field holds the algorithm and key size identifier, for example R4096 for a 4096 bit RSA key. It is expected to hold the same information for the same algorithm and key size. D1024 denotes a 1024 bit DSA key, et cetera.

The (short) key ID is the part behind the slash / -- and looking at question, it already seems to be different, anyway.

How can I get separate public and private keys?

You already have. Three pairs of public/private keys have been generated, each of them being unique. There is no such like a private key id, in OpenPGP you always reference the public key (as keys always come in pairs, anyway).

0

Finally I managed to solve my problem. Although in a different way.

I installed thunderbird, created an account for my email address. Next I installed enigmail extention. From enigmail setup wizard I created key-pair for my acoount and a revocation certificate.

But here problem was still not gone. I went to enigmail key management then right clicked on my key and selected upload to public key server. But constant error was coming. It was because enigmail was unable to add the keys to my trusted keyring.

So I once again right clicked on my key and selected export key and then enabled export of private key and clicked OK. Let us assume that I had given the name to the output file mykey-pub-sec.asc

Next I went to the terminal and typed:

cd /path/to/the/saved/file
gpg --allow-secret-key-import --import mykey-pub-sec.asc
gpg --keyserver keyserver.ubuntu.com --send-key $GPGKEY

Here I replaced $GPGKEY with the key ID

That's it job done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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