[PGP] GPG 指令指南 – GPG Commands

Intro

PGP (Pretty Good Privacy) Wiki

GPG (GNU Privacy Guard) Wiki

GPG Software Download


Commands

產生金鑰 – Generate public/private key

$ gpg --gen-key

完整產生金鑰選項:gpg --full-generate-key,含algorithm, key length, expired time

其中,Usernamepassphrase為必要。

列出金鑰 – List keys

$ gpg -k

加密 – Encryption

$ gpg -ear {Key-Name}  < plain.txt > plain.txt.asc

其中-a為輸出ASCII Armor格式,-r為指定Key的USER-ID

解密 – Decryption

$gpg -d < plain.txt.asc > plain.txt

密文裡包含Key資訊,不需額外指定Private Key

匯出金鑰 – Export

匯出Public Key:

$ gpg --export -a "{User-ID}" > public-key.asc

匯出Private Key:

$ gpg --export-secret-key -a "{User-ID}" > private-key.asc

匯入金鑰 – Import

$ gpg --import key.asc

刪除金鑰 – Delete

刪除Public Key:

$ gpg --delete-keys "{User-ID}"

刪除Private Key:

$ gpg --delete-secret-keys "{User-ID}"

Leave a Reply

Your email address will not be published. Required fields are marked *