Modify the user ID and comments of an existing gpg key.
/********************************************************************* * Author : Samson * Date : 03/18/2015 * Test platform: * gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 * GNU bash, 4.3.11(1)-release (x86_64-pc-linux-gnu) * *******************************************************************/
What should I do if I want to modify the user name and comment information of a generated gpg key pair?
Regenerate the key?
Modify the generated key?
It is easy to regenerate the key, but this will cause the selection of multiple keys. Here we will introduce how to modify the generated key.
Next let's take a look:
1. First, enter the following command on the command line to enter the interface for modifying the key information:
Gpg -- edit-key test@test.com
Gpg (GnuPG) 1.4.16; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is no warranty, to the extent permitted by law.
Private Key is available.
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
Absolute (1). yy_test1 (yy_email_gpg) <test@test.com>
Gpg>
2. Use list to view the current user's key and user ID (that is, user name, comment ):
Gpg> list
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
Absolute (1) * yy_test1 (yy_email_gpg) <test@test.com>
3. Add a user ID:
Gpg> adduid
Real name: [yy] yy Ming Xiao
Email: test@test.com
Note: DSC security
You have selected this user ID:
[Yy] yy Ming Xiao (DSC security) <test@test.com>"
Change name (N), comment (C), email address (E) or OK (O)/exit (Q )? O
You need to enter a password to unlock the user's private key: "yy_test1 (yy_email_gpg) <test@test.com>"
4096-bit RSA key, key number DPPPPPPP, established on
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
Absolute (1) * yy_test1 (yy_email_gpg) <test@test.com>
Unknown. [yy] yy Ming Xiao (DSC security) <test@test.com>
4. delete/unregister the original UID information:
Use uid 1 to select the ID to be deleted. The ID to be deleted is 1;
Gpg> uid 1
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
Absolute (1) * yy_test1 (yy_email_gpg) <test@test.com>
Unknown. [yy] yy Ming Xiao (DSC security) <test@test.com>
There are two situations,
1) Delete the key that has not been uploaded to the key server.
2) If you do not want to use the original key for a key that has been uploaded to the key server, use the logout command to log out of the key.
1) Delete the key that has not been uploaded to the key server.
Absolute (1) * marked with * indicates the selected ID, and then delete the Id 1 using the deluid command:
Gpg> deluid
Are you sure you want to delete this user ID? (Y/N) y
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
Unknown. [yy] yy Ming Xiao (DSC security) <test@test.com>
2) If you do not want to use the original key for a key that has been uploaded to the key server, use the logout command to log out of the key.
Gpg> revuid
Are you sure you want to revoke this user ID? (Y/N) y
Select the reason for revocation:
0 = unspecified reason
4 = the user ID is no longer valid
Q = Cancel
(You may want to select 4 here)
What is your decision? 4
Enter the description (optional) and end with a blank line:
>
Revocation reason: the user ID is no longer valid
(No description is given)
Can this happen? (Y/N) y
You need to enter a password to unlock the user's private key: "yy_test1 (yy_email_gpg) <test@test.com>"
4096-bit RSA key, key number DPPPPPPP, established on
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
[Revoked] (1). yy_test1 (yy_email_gpg) <test@test.com>
Unknown. [yy] yy Ming Xiao (DSC security) <test@test.com>
5. Set the trust relationship of the newly generated identity:
Gpg> trust
Pub 4096R/DPPPPPPP was created on: 2015-03-16 valid to: 2016-03-15 can be used for: SC
Trust: absolute effectiveness: absolute
Sub 4096R/PDDDDDDD created on: 2015-03-16 valid to: 2016-03-15 can be used for: E
Unknown. [yy] yy Ming Xiao (DSC security) <test@test.com>
Do you believe this user has the ability to verify the validity of other user keys (check the ID card, check through different channels)
Fingerprints, etc )?
1 = I don't know or I don't answer
2 = I don't believe
3 = I barely believe
4 = I fully believe
5 = I absolutely believe
M = return to the main menu
What is your decision? 5
Do you really want to set this key to absolute trust? (Y/N) y
After the settings are complete, the previous "unknown (1)." will change to "absolute (1).". This generally requires you to perform the save operation first and then perform the list operation again.
6. save the changes by running the save command.
Gpg> save