Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(gnupg) Which is the public and which is the private key in this pair?

Tags:

gnupg

I need to generate a PGP Public/Private key. I've never done this before. I've read documentation but the examples given do not match what I am seeing on my computer.

I generated the keys with gnupg.

I run the command to list the public keys

gpg --list-keys --keyid-format LONG

and I get a structure like this.

pub   rsa2048/123456789101112A 2000–01-01 [SC] [expires: 2000-01-01]
      ABCD1234ABCD1234ABCD1234ABCD1234ABCD1234

uid                 [ultimate] Firstname Surname <[email protected]> 
sub   rsa2048/ABCDEFGHIJKLMNO1 2000-01-01 [E] [expires: 2000-01-01]

I then run a command to get the secret keys

gpg --list-secret-keys --keyid-format LONG

and I get the same structure

sec   rsa2048/123456789101112A 2000–01-01 [SC] [expires: 2000-01-01]
      ABCD1234ABCD1234ABCD1234ABCD1234ABCD1234

uid                 [ultimate] Firstname Surname <[email protected]> 
ssb   rsa2048/ABCDEFGHIJKLMNO1 2000-01-01 [E] [expires: 2000-01-01]

What's different here is the pub, sub, sec, and ssb tags, but the content is the exact same.

Which is the public private key in each example that's generated?

Is the sequence in the first line of pub or sec after the 'rsa2048/' (123456789101112A in the example) the public key? And then the longer sequence in the line below (ABCD1234ABCD1234ABCD1234ABCD1234ABCD1234 in the example) is the matching private key?

Or is the public key the sequence in the first line of pub or sec after the 'rsa2048/' (123456789101112A in the example) and then the matching private key is the line of sub or ssb after the 'rsa2048/' (ABCDEFGHIJKLMNO1 in the example)?

like image 273
AnonyMouse Avatar asked Nov 07 '22 20:11

AnonyMouse


1 Answers

When you list your keys, pub is always your public key, and it could be saw as you "main" key. Associated with it (this "main" key), you have a private key. Any other key (sub, ssb etc.) are sub-keys that are private. In order to get the meanings for sec, sub, ssb & pub, you can read this post: gnupg - What do 'ssb' and 'sec' mean in gpg's output

I hope this could solve your 'problem'.

like image 200
alencc1986 Avatar answered Nov 29 '22 16:11

alencc1986