8

I was following this instruction to install VirtualBox on my Ubuntu 20.04 LTS machine.

As per instruction I registered the public key:

wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg

They state that the fingerprint for oracle_vbox_2016.asc is

B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>

Now, I am trying to verify the fingerprint but I have trouble extracting the fingerprint from the .gpg file.

For example, if I use the following command, it outputs some information but not the fingerprint:

gpg --with-fingerprint /usr/share/keyrings/oracle-virtualbox-2016.gpg

What command do I have to use to extract the fingerprint from the oracle-virtualbox-2016.gpg file?

Tando
  • 115

3 Answers3

6

Welcome Tando to Superuser,

You can check the fingerprint of the pubic key in the keyring with the following command:

gpg --no-default-keyring --keyring /usr/share/keyrings/oracle-virtualbox-2016.gpg --fingerprint
4

Using gpg version 2.2.27

gpg --version

output

gpg (GnuPG) 2.2.27 libgcrypt 1.9.4

Download the current .asc file from https://www.virtualbox.org/wiki/Linux_Downloads as of this writing (2023-03-22):

wget https://www.virtualbox.org/download/oracle_vbox_2016.asc

The VirtualBox website currently states:

The key fingerprint for oracle_vbox_2016.asc is

B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>

The following commands all allow to verify this information, each with different formatting:

gpg --show-keys --with-fingerprint --keyid-format=short oracle_vbox_2016.asc

Output:

pub   rsa4096/2980AECF 2016-04-22 [SC]
      Key fingerprint = B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
uid                    Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
sub   rsa4096/920E471F 2016-04-22 [E]

gpg --show-keys --with-fingerprint oracle_vbox_2016.asc

Output:

pub   rsa4096 2016-04-22 [SC]
      B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
uid                      Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
sub   rsa4096 2016-04-22 [E]

gpg --show-keys oracle_vbox_2016.asc

Output:

pub   rsa4096 2016-04-22 [SC]
      B9F8D658297AF3EFC18D5CDFA2F683C52980AECF
uid                      Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
sub   rsa4096 2016-04-22 [E]

gpg --show-keys --with-colons oracle_vbox_2016.asc

Output ("The --with-colons option emits the output in a stable, machine-parseable format, which is intended for use by scripts and other programs."):

pub:-:4096:1:A2F683C52980AECF:1461318881:::-:::scESC::::::23::0:
fpr:::::::::B9F8D658297AF3EFC18D5CDFA2F683C52980AECF:
uid:-::::1461318881::CA5D570DDFDB695A0301885765DD8E285368742C::Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>::::::::::0:
sub:-:4096:1:AD18C79D920E471F:1461318881::::::e::::::23:
fpr:::::::::31DD01EB8C64DF3D12E7BC97AD18C79D920E471F:
Abdull
  • 2,432
0

This worked for me:

gpg --show-keys --with-colons myfile.gpg | \
  awk -F: '$1=="pub",($1!="pub"&&$2=="-"){if($1=="fpr"){print$10}}'

The output of --with-colons looks like this:

pub:-:2048:1:8E6DA8B4E158C569:1312374466:1753592943::-:::scESC::::::23::0:
fpr:::::::::30EBF4E73CCE63EEE124DD278E6DA8B4E158C569:
uid:-::::1595912943::D667E327D458366CD303BF42601CC4A97D61B61B::Samuli Seppänen (OpenVPN Technologies, Inc) <samuli@openvpn.net>::::::::::0:
sub:-:2048:1:D4BC7371F5699905:1312374466:1753593039:::::e::::::23:
fpr:::::::::A3035CCD73A6443269706156D4BC7371F5699905:

The awk flag -F: splits the input on :. (Alternatively this could be a part of the program as BEGIN { FS=":" }.)

The following range pattern matches all lines between pub:... and any line whose second column is -. Which extracts just the part nested inside pub:.... Finally the expression in {} prints out the 10-th column which contains the fingerprint.

Petr
  • 3,273