~/basic GPG commands

Jun 15, 2022


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Generate a new GPG key
gpg --full-generate-key

# List all GPG keys
gpg --list-keys

# List private keys
gpg --list-secret-key

# Export a public key
gpg --export --armor <key-id> > publickey.asc

# Export a private key
gpg --export-secret-key --armor <key-id> > privatekey.asc

# Import a public key
gpg --import publickey.asc

# Import a private key
gpg --import privatekey.asc

# Encrypt a file
gpg --encrypt --recipient <key-id> <file>

# Decrypt a file
gpg --decrypt <file>.gpg

# Sign a file
gpg --sign <file>

# Verify a signed file
gpg --verify <file>.sig

# Encrypt and sign a file
gpg --encrypt --sign --recipient <key-id> <file>

# Delete a public key
gpg --delete-key <key-id>

# Delete a private key
gpg --delete-secret-key <key-id>

References

Tags: [gpg]