gpg

```
[linuxstudy@xxxx ~]$ gpg --gen-key
gpg (GnuPG) 2.0.22; 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.

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? 
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 1y
Key expires at Fri 26 Jul 2024 08:00:38 PM JST
Is this correct? (y/N) y

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

Real name: linuxstudy
Email address: linux@gmail.com
Comment: 
You selected this USER-ID:
    "linuxstudy <linux@gmail.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret 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 4EAB5381 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
gpg: next trustdb check due at 2024-07-26
pub   2048R/4EAB5381 2023-07-27 [expires: 2024-07-26]
      Key fingerprint = 0244 6556 51E9 6C39 712E  A56A D787 6D95 4EAB 5381
uid                  linuxstudy <linux@gmail.com>
sub   2048R/5FB8E757 2023-07-27 [expires: 2024-07-26]
```
```
[linuxstudy@xxxx ~]$ ls .gnupg
private-keys-v1.d  pubring.gpg  pubring.gpg~  random_seed  secring.gpg  S.gpg-agent  trustdb.gpg
```
```
[linuxstudy@xxxx ~]$ gpg --export linux@gmail.com > gpg-pub-linuxstudy.key
[taro@xxxx ~]$ gpg --import gpg-pub-linuxstudy.key 
gpg: directory `/home/taro/.gnupg' created
gpg: new configuration file `/home/taro/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/taro/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/taro/.gnupg/secring.gpg' created
gpg: keyring `/home/taro/.gnupg/pubring.gpg' created
gpg: /home/taro/.gnupg/trustdb.gpg: trustdb created
gpg: key 4EAB5381: public key "linuxstudy <linux@gmail.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
[taro@xxxx ~]$ gpg --list-keys
/home/taro/.gnupg/pubring.gpg
-----------------------------
pub   2048R/4EAB5381 2023-07-27 [expires: 2024-07-26]
uid                  linuxstudy <linux@gmail.com>
sub   2048R/5FB8E757 2023-07-27 [expires: 2024-07-26]

[taro@xxxx ~]$ vi secret-doc.txt
[taro@xxxx ~]$ gpg --encrypt --recipient linux@gmail.com secret-doc.txt 
gpg: 5FB8E757: There is no assurance this key belongs to the named user

pub  2048R/5FB8E757 2023-07-27 linuxstudy <linux@gmail.com>
 Primary key fingerprint: 0244 6556 51E9 6C39 712E  A56A D787 6D95 4EAB 5381
      Subkey fingerprint: A0C2 BD37 5060 D449 B468  664F 9A39 CA01 5FB8 E757

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
[linuxstudy@xxxx ~]$ gpg --output secret-doc-decrypt.txt --decrypt secret-doc.txt.gpg
You need a passphrase to unlock the secret key for
user: "linuxstudy <linux@gmail.com>"
2048-bit RSA key, ID 5FB8E757, created 2023-07-27 (main key ID 4EAB5381)

gpg: encrypted with 2048-bit RSA key, ID 5FB8E757, created 2023-07-27
      "linuxstudy <linux@gmail.com>"
[linuxstudy@xxxx ~]$ cat secret-doc-decrypt.txt this is secret document.
```