linux:misc:pgp_keys_cli

Working with PGP keys in linux terminal

Import public key

user@example:~$ gpg --import user.asc
gpg: /home/user/.gnupg/trustdb.gpg: trustdb created
gpg: key F8F693CC: public key "User <user@example.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
user@example:~$

Edit key trust

user@example:~$ gpg --edit-key user@example.com
gpg (GnuPG) 1.4.12; Copyright (C) 2012 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.
 
 
pub  2048R/F8F693CC  created: 2016-05-05  expires: never       usage: SC
                     trust: unknown       validity: unknown
sub  2048R/0672AF0A  created: 2016-05-05  expires: never       usage: E
[ unknown] (1). User <user@example.com>
 
gpg> trust
pub  2048R/F8F693CC  created: 2016-05-05  expires: never       usage: SC
                     trust: unknown       validity: unknown
sub  2048R/0672AF0A  created: 2016-05-05  expires: never       usage: E
[ unknown] (1). User <user@example.com>
 
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)
 
  1 = I don't know or won't say
  2 = I do NOT trust
  3 = I trust marginally
  4 = I trust fully
  5 = I trust ultimately
  m = back to the main menu
 
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
 
pub  2048R/F8F693CC  created: 2016-05-05  expires: never       usage: SC
                     trust: ultimate      validity: unknown
sub  2048R/0672AF0A  created: 2016-05-05  expires: never       usage: E
[ unknown] (1). User <user@example.com>
Please note that the shown key validity is not necessarily correct
unless you restart the program.
 
gpg> q
user@example:~$

Encrypt text

user@example:~$ echo "text to be encrypted" | gpg --no-secmem-warning --encrypt --armor --local-user no-reply@example.com --recipient user@example.com
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.12 (GNU/Linux)
 
hQEMA0KFSn8Gcq8KAQf9HW08i3O3pOOlFblN8oF67ShARsAz66kihMvpushRzYLf
4FZ9qwsoUvMjqHsvTbiR44lAOAeuW35rZO6CYteZuwkCoN0sF8GyY3Ta2PHTw+zK
iTF8lIVSd4ufreV7ziZFLVSaEUDub8KY89+36wpCm3CkSqbWwd7TN2mlGJv2Wo/Q
9ioN6C6IjM0jfmpfF1/JPVWsIK+hB/KBHepsR04ZhJdbw1InZvrg0aoB0Vn1hycl
UHqLKae4zLe8SSAL+BUvA1xablKAyta8sTIrwdgoMqvtdBkneiNcjGPg28WrCjrp
rl6Erk9URXF0hfz6o00ENHfVExfPha3ER7daQqrgR9JQAWwZzmoagVKidISzMrS8
toI4S92cYQUXP58yGZj3BJL+FGYy0tGXTvPYYQZYSP6o/SHYltB9/Y7Tr8IPt0Nl
34UMJ++K1hUzgdNZlTo831g=
=3lj3
-----END PGP MESSAGE-----
user@example:~$
  • linux/misc/pgp_keys_cli.txt
  • Last modified: 2019/10/31 09:05
  • by 127.0.0.1