Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux instructions and examples GPG encryption and decryption     - Database Blob data type conversion String (Programming)

- Httpclient4.4 of principle (Http execution context) (Programming)

- Linux system Iptables Firewall User Manual (Linux)

- How to make a U disk to install Ubuntu (Linux)

- Linux program analysis tool: ldd and nm (Linux)

- Ubuntu users to install voice switch instructs the applet (Linux)

- Database start listening TNS-12537, TNS-12560 error (Database)

- Rman Oracle database backup and recovery plan (Database)

- Category prevent DoS attacks against Linux (Linux)

- Ubuntu install Eclipse can not find JAVA_HOME problem (Linux)

- Linux Creating a new user error Creating mailbox file: File exists (Linux)

- Ubuntu 14.04.02 LTS startup items erroneous writing / dev / sda1 (win 7 loader) Repair (Linux)

- Disk partition MBR (Linux)

- Create RAID 1 (mirroring) with two disks (Linux)

- How to install and use the malware detection tool LMD and ClamAV antivirus engine on Linux (Linux)

- Ubuntu use three methods to install Ruby (Linux)

- Getting Started with Linux: Learn how to install and access CentOS 7 Remote Desktop on a VPS (Server)

- Ftp user to create multiple virtual machines to support different access rights Examples (Server)

- Easy to install Ubuntu 15.04 and Ubuntu 15.04 GNOME on Wayland trial (Linux)

- Schema snapshot rollback (Database)

  Linux instructions and examples GPG encryption and decryption
  Add Date : 2017-08-31      
  1, generate the key pair: gpg --gen-key

For the user to generate a new key pair. Required: key type (the default is RSA / RSA); key length (in units of bits, the longer the strong); expiration time (to prevent key damage); (I usually enter all the way in the past) then down or to fill a fill: name, e-mail, identify the owner of the key comments; passphrase (must be provided, if the private key is stolen, can not be used).

2, listed public: gpg --list-keys

Lists have public: their own public as well as any public keys from others with which it communicates to import.

3. Export the public key: gpg --export --armor key-id -o file.key

Export the public key to a file for use in other people. --armor option output in text form, rather than in binary format. key-id is the eight-digit hexadecimal number or e-mail address listed in the --list-keys in the pub row.

4, import the public: gpg --import file.key

Import other people's public key from the key file sent to you in

5, the encrypted file: gpg --encrypt --armor -r key-id file

key-id's public key to encrypt the message using. If no -r key-id, command prompts the recipient input. The default output file is file.asc.

6, decrypt the file: gpg --decrypt file

In one of your private key to decrypt messages encrypted with the public key.


Create your own public / private key pair.

[Sjx @ server1 ~] $ gpg --gen-key

gpg (GnuPG) 2.0.14; Copyright (C) 2009 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.

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)

Your selection? Enter

RSA keys may be between 1024 and 4096 bits long.

What keysize do you want? (2048) Enter

Requested keysize is 2048 bits

Please specify how long the key should be valid.

0 = key does not expire

= key expires in n days

w = key expires in n weeks

m = key expires in n months

y = key expires in n years

Key is valid for? (0) Enter

Key does not expire at all

Is this correct? (Y / N) y

GnuPG needs to construct a user ID to identify your key.

Real name: shangjx

Email address: shangjx13@gmail.com

Comment: Enter

You selected this USER-ID:

"Xiyou "

Change (N) ame, (C) omment, (E) mail or (O) kay / (Q) uit? O

You need a Passphrase to protect your secret key.

can not connect to `/home/linuxhost/.gnupg/S.gpg-agent ': No such file or directory

gpg-agent [2008]: directory `/home/linuxhost/.gnupg/private-keys-v1.d 'created

(Graphics application will pop up, enter and verify key)

We need to generate a lot of random bytes. It is a good idea to perform

some other action (type on the keyboard, move the mouse, utilize the

disks) during the prime generation; this gives the random number

generator a better chance to gain enough entropy.

We need to generate a lot of random bytes. It is a good idea to perform

some other action (type on the keyboard, move the mouse, utilize the

disks) during the prime generation; this gives the random number

generator a better chance to gain enough entropy.

gpg: key CA83F5AF marked as ultimately trusted

public and secret key created and signed.

gpg: checking the trustdb

gpg: 3 marginal (s) needed, 1 complete (s) needed, PGP trust model

gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u

pub 2048R / CA83F5AF 2011-08-15

Key fingerprint = F886 17A2 F832 B545 6E27 B424 E539 26BF CA83 F5AF



sub 2048R / DB58BFCE 2011-08-15

To export the key, look for the key ID in the above output. You can back above pub 2048R / output found. In the example given

Key ID is CA83F5AF. The following example shows using the command that key ID's.

Export your public key, shared with partners.

[Linuxhost @ server1 ~] $ gpg -a -o ~ / pub.key --export CA83F5AF

Export the public key copied onto server2 partners.

[Linuxhost @ server1 ~] $ scp pub.key server2.example.com:~

Import the public partners.

[Linuxhost @ server2 ~] $ gpg --import pub.key

gpg: directory `/home/linuxhost/.gnupg 'created

gpg: new configuration file `/home/linuxhost/.gnupg/gpg.conf 'created

gpg: WARNING: options in `/home/linuxhost/.gnupg/gpg.conf 'are not yet active during this run

gpg: keyring `/home/linuxhost/.gnupg/secring.gpg 'created

gpg: keyring `/home/linuxhost/.gnupg/pubring.gpg 'created

gpg: /home/linuxhost/.gnupg/trustdb.gpg: trustdb created

gpg: key CA83F5AF: public key "westos < linuxhost@server1.example.com>" imported

gpg: Total number processed: 1


imported: 1 (RSA: 1)

Create a text file that contains the message for reading partners.

[Linuxhost @ server2 ~] $ echo "xi'an university of posts and telecommunications"> encrypt.txt

Files encrypted with the public partner.

[Linuxhost @ server2 ~] $ gpg --encrypt --armor -r CA83F5AF encrypt.txt

gpg: CA83F5AF: There is no assurance this key belongs to the named user

pub 2048R / CA83F5AF 2011-08-15 xiyou < sjx@server1.example.com>

Primary key fingerprint: 7F44 7AE0 A7C2 6E89 6C68 6FE2 5572 8249 3F7B CEB5

Subkey fingerprint: 8FCB BF3E 2D51 563F 1C3F 2440 FC81 0D73 A353 A3BF

It is NOT certain that the key belongs to the person named

in the user ID. If you * really * know what you are doing,

you may answer the next question with yes.

Use this key anyway? (Y / N) y

The encrypted file replication partners.

[Linuxhost @ server2 ~] $ scp encrypt.txt.asc server1.example.com:~

Decryption partner encrypted files and verify that you can view the messages that they send.

[Linuxhost @ server1 ~] $ gpg --decrypt encrypt.txt.asc

You need a passphrase to unlock the secret key for

user: "xiyou < sjx @ localhost>"

2048-bit RSA key, ID DB58BFCE, created 2011-08-15 (main key ID CA83F5AF)

can not connect to `/home/linuxhost/.gnupg/S.gpg-agent ': No such file or directory

gpg: encrypted with 2048-bit RSA key, ID DB58BFCE, created 2011-08-15

"Xiyou < sjx@server1.example.com>"

xi'an university of posts and telecommunications
- Oracle index visible and hidden (visible / invisible) (Database)
- Oracle 11g users to create, authorize and import dmp file (Database)
- Upgrading Oracle to (Database)
- Linux foreground to background process switch (Linux)
- Linux performance monitoring (Linux)
- CentOS 7 virt-manager can not connect a local hypervisor (Linux)
- How to set up FTP server on Linux (Server)
- Linux shell script debugging (Linux)
- Make command tutorial (Linux)
- Docker command Detailed (Linux)
- Ubuntu Control Panel to resolve network-manager icon display issue (Linux)
- Ubuntu 12.04 64bit Install Source Insight 3.5 and create desktop icons (Linux)
- Nginx1.8 version upgrade method AMH4.2 Free manually compile (Server)
- Linux Command - ps: a snapshot of the current process (Linux)
- Java Concurrency: synchronized (Programming)
- Linux LVM - File system extension (Linux)
- Getting Started with Linux system to learn: How do I know which processes are running on the CPU core (Linux)
- SLF4J Tutorial (Programming)
- Linux System Getting Started Learning: Using yum to download the RPM package without installing (Linux)
- How to configure a server in a MySQL Cluster (Database)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.