Detailed explanation of ubuntu using gpg2

installation##

apt-get install gnupg2

Generate key pair##

gpg2 --full-generate-key
# Then, just fill in as prompted
gpg2 --list-keys
# Output
pub   rsa2048 2020-01-02[SC]
  6 CFAA44AC11E041B0181988352FC3xxxxC39FF406
uid           [absolute] haha <[email protected]>
sub   rsa2048 2020-01-02[E]

Note that this [email protected] is the user ID
6 CFAA44AC11E041B0181988352FC3xxxxC39FF406 is the user ID

Export public key##

gpg2 --armor --output ~/public-key.txt --export [email protected]

Now in the ~ directory, your public key will appear

Export private key##

gpg2 --armor --output ~/private-key.txt --export-secret-keys [email protected] 

Upload the public key to the server##

# 6 CFAA44AC11E041B0181988352FC3xxxxC39FF406 is the user identification, in--list-keys can be viewed
gpg2  --keyserver hkp://keyserver.ubuntu.com --send-keys 6CFAA44AC11E041B0181988352FC3xxxxC39FF406

At this point, you can search for your public key##

gpg2  --keyserver hkp://keyserver.ubuntu.com --search-keys "[email protected]"

Here is a screenshot:

Download public key##

# First search [email protected], figure out the id, then
gpg2 --keyserver keyserver.ubuntu.com --recv 52FC3B13C39Fxxx6

at this time:

gpg2 --list-keys
/root/.gnupg/pubring.kbx
------------------------
pub   rsa2048 2020-01-02[SC]
  6 CFAA44AC11E041B01819883xxxxxxx9FF406
uid           [ unknown] xxxxx <[email protected]>
sub   rsa2048 2020-01-02[E]

The public key can be found.

encryption##

gpg2 --recipient [email protected] --output test2.txt --encrypt test.txt

After importing the public key, you can use the public key to encrypt. test.txt is the source file, test2.txt is the encrypted file

Decryption##

Send the encrypted file to the party who has the private key.

gpg --recipient [email protected] --output testde.txt --decrypt ./test2.txt

At this time, you will be asked to enter the protection password when creating the key pair. After entering the password, the testde.txt file is generated.

Recommended Posts

Detailed explanation of ubuntu using gpg2
Detailed explanation of static DNS configuration method in Ubuntu
Detailed explanation of static DNS configuration under Ubuntu system
Detailed explanation of python backtracking template
Detailed explanation of python sequence types
Detailed explanation of quick installation and configuration of Subversion (SVN) under Ubuntu
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Detailed explanation of Python IO port multiplexing
Detailed explanation of -u parameter of python command
Detailed explanation of Python guessing algorithm problems
Ubuntu20.04 install Python3 virtual environment tutorial detailed explanation
Detailed explanation of the principle of Python super() method
Detailed explanation of python standard library OS module
Talking about the first experience of using Ubuntu
Detailed explanation of the usage of Python decimal module
Detailed explanation of how python supports concurrent methods
Detailed explanation of data types based on Python
Detailed explanation of building Hadoop environment on CentOS 6.5
Detailed examples of using Python to calculate KS
Detailed explanation of Centos 7 system virtual machine bridging mode
Detailed explanation of the principle of Python function parameter classification
Detailed explanation of the principle of Python timer thread pool
Detailed explanation of the implementation steps of Python interface development
Detailed explanation of common tools for Python process control
Detailed explanation of Python web page parser usage examples
Detailed explanation of the attribute access process of Python objects
Detailed explanation of the remaining problem based on python (%)
Python—requests module detailed explanation
3D effect of ubuntu
Equal Insurance Evaluation: Detailed Explanation of Centos Timeout Exit
Summary of ubuntu usage
Detailed explanation of CentOS7 network setting tutorial in vmware
Detailed explanation of Spark installation and configuration tutorial under centOS7
Use of Anaconda in Ubuntu
ufw of ubuntu firewall rules
Detailed ubuntu 20.04 LTS installation record
Use of mediawiki under ubuntu
Summary of various ubuntu problems
Initial setup of Ubuntu 16.04 server