In this video you learn about GPG. So what is GPG? It's a GNU privacy guard. It's a tool
for encryption, signing and verification that is based on public key cryptography. The common
cryptography that you will find, for instance, in TLS cryptography as well. In GPG, every
single user has a key pair, and this key pair can be used for different reasons. Now, in
the key pair, the private key is kept by the user. It's a big secret. It should never be
shared. And the public key is what is going to be shared with other users. Now, GPG works
at the notion of a key ring, and the key ring is what can be used to keep other users' keys.
And the following procedure describes how user Anna creates a key pair and what needs
to be done by user Linda to send her an encrypted file. I'm going to run this procedure for
you so that you can see how it works. All right, let me create GPG configuration for
user Anna, and let's have Anna communicate with user Linda in a GPG encrypted way. Now,
in order to do so, I'm using SSH Anna at localhost. You should know that many things don't really
work well in an SU-minus subshell, and that is why I'm using SSH to open a login shell,
which is not the same as a subshell. Likewise for user Linda, Linda at localhost. All right,
now, as user Anna, I'm going to use the command GPG minus minus full generate key, and that
will create the key pair. Just pressing enter for all the default answers. I don't care too
much about all these settings. It's interesting to have a look at them if you want it to be more
secure, but for generic use and for a first try, default settings are doing all right. So we need
a real name. So real name is Anna example. And this real name obviously is important for the
users of the key to identify the user from whom they received the key. I have no comment and I'm
doing an O for okay. And there we can see that the user is prompted for a passphrase. This
passphrase is for usage of the private key, and it's a good idea to use a pretty secure passphrase.
Oops, what do we see? I have entered an insecure passphrase. Okay, let me do it again. And let me
make the passphrase a little bit more secure. So there we go and pressing OK. Now next it is doing
what it is giving some information about entropy. Entropy is based on random data that needs to be
generated for the user. And in the end, the key is is here. So what am I going to do? Well, I am
going to use a GPG minus minus export minus eight. And I'm calling it anarchy. And I'm writing this
anarchy to anarchy.asc. Okay, next thing user Anna needs to do is GPG export to some file pubkey.asc. And
there we go. User Anna needs to distribute this this key. Normally, she will send it by email or
whatever. I am going to copy the anarchy to the TMP directory so that it will be available for use
for Linda as well. So here as usual, Linda, I'm using GPG minus minus import of TMP and pubkey. And
there we can see that the key has been imported. And GPG minus K is showing that the key from the user
ID Anna example is is available. So I can use GPG minus minus fingerprint Anna to show the key
fingerprint. And there we go. So now I'm going to add to create a file echo hello greater than secrets
dot txt. That is going to be my very secure file. And next as usual, Linda, I'm going to use GPG minus
e minus r Anna of this secrets dot txt. So here we can see that I haven't trusted the key yet. That's a
different procedure. I'm going to use the key anyway. And the result is listed right here secrets dot
txt dot GPG. That's my encrypted file. I'm going to copy my secrets txt dot GPG to the TMP directory because
that's an easy way for user Anna to pick it up. And next user Anna is doing a cat on TMP secrets, txt and
that's unreadable. And now if user Anna is using GPG minus D instead, then she will create the decrypted
version of the file. And in order to do so, user Anna needs to authorize by entering the passphrase. And she
just entered the passphrase. And here we can see that user Anna has successfully decrypted the secrets dot txt.
And that is how you can work with GPG. Now let's talk about some common GPG tasks. So you can use GPG minus e
minus r Anna, my secrets dot txt in the way we have just done it to encrypt the file. GPG minus D decrypts the
file. You can also sign the file to prove ownership. And in order to do so, GPG minus s is the command. GPG minus
verify allows you to verify a file signature. And if you want to do that on ISOs and downloads, you use GPG minus
minus verify sha256sums.gpg on sha256sums because these are commonly used for downloads as well as ISOs. GPG minus
minus list keys or just GPG minus k will list all keys currently installed. And that is what you should know about
GPG.