0

A colleague of mine gave me their public key in text format and now I want to use that public key to encrypt my plain messages.

The thing is, I don't know how to create a key for an existing public key. As in how do I import the public key in GnuPG if I only have the public key in an email message? Like I know how to generate a random new key, just now how to create or import a public key

This is the public key given to me:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: OpenPGP.js v3.0.9
Comment: https://openpgpjs.org

xsBNBFu4XWABCAD3CPThI8OyFNnvKsxdG5IxiGNWXrlN/Rw8Ors16TkSAsNg
j9s898/k9FZn9YiRGWG60zlfedgl0mQtHU+w/FBdgSV3EqVaUPjPsFGEq6eD
WOXKSPeTdhuYaM8wxt0ru7llLjxKBc6kw1CyXP+Da/gZLIX756KhqqDIlAKr
cx8oh4mvxpkj7L3qACDKIenJevhrz/iUIbnyBpd76qKQp0xojcqsqh7KXziC
xOiIL01lT130Hzd2FvcKiPlvbcKp7WJJy6cc9dKQ/3bSM6dqOQshqfUtWmxr
TU7s7jGGuexsTX5Bd/Rss2yTLv4Cn2MlNnOzcioUgE7XhKHvYZCFX3TvABEB
AAHNHFJlemFyaW9zIDxnYW51QGVvczJtYWlsLmNvbT7CwHUEEAEIACkFAlu4
XWAGCwkHCAMCCRCEnF0xNji/7gQVCAoCAxYCAQIZAQIbAwIeAQAAYKwH/0L5
TwxJPcAfv8/5Ku+VcSixnDmkHaVc4zd9VWpxDX9MpOmqNYOXwlHzKl1h2hm8
/M91fO+NOGxugDRathEtmlWrnE+/3X6nLhU63xtaj23cK17WfcU8xGzPpzPD
iRqMt4HwQlIby/Zp2GqhoxjRfYIULYtwubpsCZLoQtyUqR1c/JTYScWm51UP
CP8VyzqWBYgznI2yf5ODl4aOXN3S3Z1CaItcJcAcwomye14dfabVnPkQhlD2
BCr8kfBj3Y49PO60PUuaoes3t8ZTDpxHQTfAdx9ZNe53jy7FXMfOuYvdQWve
aG5SYP4hTVcSD8L/C3AnPcuqLR380A0qYqtKe5fOwE0EW7hdYAEIAMF/O+cI
mzCVH5U7xRZVy6gvQAwO+sHScUwaIYB0akst1Qocc3LcRV0C5qwu/gCYthIE
onShp1CNBgSuPUB6n1LlqV4/hvujSxBKycl3rKlasf1BWBLIlZk3cIDcZ8JH
crdXbpoEfHCUcE8D3mpLopC+2zF/uKeityhZwiOiWbmkqfqWibepUs2Y7f9E
x9ncIb8joEXzpZpW6YTVjZz7v7mcOnyNn/5HY4X+EI5Uk/SNXmm63j5IjBHz
34QPhLCaVm73Zo9FxDzau6bDlFhgyZ9yntuCi2QRQJqCSu/XU6KZ1PSzy/pO
wl8YQybJMe9+OP+BfbvDdXVXayzddRzFXpcAEQEAAcLAXwQYAQgAEwUCW7hd
YAkQhJxdMTY4v+4CGwwAANAlCAC0mQ9KsEThyPa6iygn9+MyIUY81XGxG9pY
1FbprCtRsIbB/YZ4hTdIwreW2uIllgMEizbMCUYFDNOrrftf8cZbuB3aEeu7
kiPa8cw6sIt/VDHtY9Z+NOQoPy4TtS7u4u8yJgi1/z79AGyncAakBg0FfSkV
EmbolYNRcvDt+/UQZ6L2cfn1nmeFhXWFZKV0TzI0W3JxAekaWfmxi7qQAeE/
BcQy1IrFkNSbHmSE1n9hj07BmlKW5dBavRxo6eOjS7nycx7WYf5Abq7ABAN+
LSBSJ9UYmph8Lc5bJFpP1LEmC4PXE7tZ9bhG7QseNyaEoMOcwZpkO0COzgGJ
yaBBfP21
=jHTx
-----END PGP PUBLIC KEY BLOCK-----

Once imported, would I encrypt my plaintext in the following manner:

echo "New to the game" | gpg -e -r recipient_userid textfile

I know it may seem easy to some, but it has been driving me mad only because I don't know how to create a file which has my colleagues public key in it

1 Answers1

0

This is a valid OpenPGP key file. Just store it into a text file (using a proper text editor which does not "fiddle" with the characters or newlines, so MS Office or Libreoffice do not qualify here) and rund gpg --import <path-to-keyfile>.

Usually the ASCII-armored keys (the base64-like copy you posted here) are stored with .asc extension, but this is not really important especially when working on the command line. If you want to import the key using a graphical user interface (by double clicking, ...) the extension might be important, though.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96