2025-03-14 21:59:59 -06:00
|
|
|
# gpg
|
|
|
|
|
|
|
|
|
|
> GNU Privacy Guard。
|
2025-04-03 20:36:56 -06:00
|
|
|
> もっと詳しく: <https://gnupg.org/documentation/manuals/gnupg/Invoking-GPG.html>。
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- GPGの公開鍵と秘密鍵を対話的に作成する:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`gpg {{[--full-gen-key|--full-generate-key]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 暗号化せずに `doc.txt` に署名する (出力を `doc.txt.asc` に書き出す):
|
|
|
|
|
|
|
|
|
|
`gpg --clearsign {{doc.txt}}`
|
|
|
|
|
|
|
|
|
|
- alice@example.com と bob@example.com の `doc.txt` を暗号化して署名する (`doc.txt.gpg` に出力):
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`gpg {{[-es|--encrypt --sign]}} {{[-r|--recipient]}} {{alice@example.com}} {{[-r|--recipient]}} {{bob@example.com}} {{doc.txt}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- パスフレーズのみで `doc.txt` を暗号化する (`doc.txt.gpg` に出力):
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`gpg {{[-c|--symmetric]}} {{doc.txt}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- `doc.txt.gpg` を復号化する (`stdout` に出力):
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`gpg {{[-d|--decrypt]}} {{doc.txt.gpg}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 公開鍵をインポートする:
|
|
|
|
|
|
|
|
|
|
`gpg --import {{public.gpg}}`
|
|
|
|
|
|
|
|
|
|
- alice@example.com 用に公開鍵をエクスポートする (`stdout` に出力):
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`gpg --export {{[-a|--armor]}} {{alice@example.com}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- alice@example.com の秘密鍵をエクスポートする (`stdout` に出力):
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`gpg --export-secret-keys {{[-a|--armor]}} {{alice@example.com}}`
|