How to verify your Ubuntu download

Key Value
Summary Verifying your ISO helps insure the data integrity and authenticity of your download.
Categories desktop
Difficulty 3
Author Canonical Web Team webteam@canonical.com

Overview

Duration: 0:02

While we hope you can usually trust your Ubuntu download, it is definitely reassuring to be able to verify that the image you have downloaded is not corrupted in some way, and also that it is an authentic image that hasn’t been tampered with.

What you’ll learn

  • How to use gpg tools to verify the authenticity of a file
  • How to use sha256 tools to verify the integrity of a file

What you’ll need

  • Access to the command line gpg tools
  • Internet access to download the signatures

Originally authored by Canonical Web Team

Necessary software

Duration: 0:02

The key executables you will require are sha256sum, md5sum and gpg.

For Ubuntu

These are part of the coreutils and gnupg packages, which are installed by default.

For Windows

If you are using bash on Windows 10 (why on earth not? See this tutorial), these tools are part of the default install.

For macOS

You can install the latest GnuPG using Homebrew:

brew install gnupg

The sha256sum program and other useful utilities are provided by coreutils:

brew install coreutils

For other versions of Linux

Your mileage may vary, but these are standard tools included and enabled by default in most systems. If you don’t have them, check with your package manager and search for the executable names given above.

All versions - check the commands are working!

You can check the commands work as expected by running the following:

gpg --list-keys

If this is the first time you have run gpg, this will create a trust database for the current user.

md5sum --version
sha256sum --version

Both these commands should output some version information. Now we have the tools we need, we can move on to finding and downloading the files we need

Download checksums and signatures

Duration: 0:01

Alongside the actual ISO files containing the Ubuntu image you downloaded, all Ubuntu mirrors publish some extra files. The ones we are interested in are called:

SHA256SUMS                                    
SHA256SUMS.gpg  

It is usually convenient to download these at the same time as downloading the distro. However, if you didn’t, not to worry - the checksums and the signature are consistent for the image, so even if you downloaded your ISO file from a different source, as long as it is fresh and hasn’t been updated in the interim, you can fetch these files from the http://releases.ubuntu.com page for the relevant release. You will usually find the relevant files on the top of the directory listing.

ⓘ Note - some people question that if the site they are downloading from is not secure (many archive mirrors do not use SSL), how can they trust the signatures? The gpg fingerprint is checked against the Ubuntu keyserver, so if the signature matches, you know it is authentic no matter where/how it was downloaded!

The SHA256SUMS file contains checksums for all the available images (you can check this by opening the file) where a checksum exists - development and beta versions sometimes do not generate new checksums for each release.

The SHA256SUMS.gpg file is the GnuPG signature for that file. In the next step we will use this signature file to verify the checksum file.

Retrieve the correct signature key

Duration: 0:04

Depending on your platform, you may or may not need to download the public key used to authenticate the checksum file (Ubuntu and most variants come with the relevant keys pre-installed). The easiest way to find out if you need the key is to run the authentication command:

gpg --keyid-format long --verify SHA256SUMS.gpg SHA256SUMS

We use GnuPG’s “long” (64-bit) key IDs throughout this tutorial, since “short” (32-bit) key IDs are insecure.

If you don’t have the keys…

If there is no public key for Ubuntu already present, you will get an error message similar to the following:

gpg: Signature made Thu Apr  5 22:19:36 2018 EDT
                    using DSA key ID 46181433FBB75451
gpg: Can't check signature: No public key
gpg: Signature made Thu Apr  5 22:19:36 2018 EDT
                    using RSA key ID D94AA3F0EFE21092
gpg: Can't check signature: No public key

This is actually a really useful message, as it tells us which key or keys were used to generate the signature file. Knowing these ID numbers (46181433FBB75451 and D94AA3F0EFE21092 in the example), means we can request them from the Ubuntu key server.

This is done with the following command. Note that the ID numbers are hexadecimal, so we prefix them with 0x:

gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x46181433FBB75451 0xD94AA3F0EFE21092

This command should retrieve the keys we want and add them to your keyring. You should see a message like this:

gpg: requesting key 46181433FBB75451 from hkp server keyserver.ubuntu.com
gpg: requesting key D94AA3F0EFE21092 from hkp server keyserver.ubuntu.com
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 46181433FBB75451: public key "Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>" imported
gpg: key D94AA3F0EFE21092: public key "Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 2  (RSA: 1)

You can now inspect the key fingerprints by running:

gpg --keyid-format long --list-keys --with-fingerprint 0x46181433FBB75451 0xD94AA3F0EFE21092

…which should produce the following output:

pub   dsa1024/46181433FBB75451 2004-12-30 [SC]
      Key fingerprint = C598 6B4F 1257 FFA8 6632  CBA7 4618 1433 FBB7 5451
uid                  Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>

pub   rsa4096/D94AA3F0EFE21092 2012-05-11 [SC]
      Key fingerprint = 8439 38DF 228D 22F7 B374  2BC0 D94A A3F0 EFE2 1092
uid                  Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>

Verify the SHA256 checksum

Duration: 0:02

Now you can verify the checksum file using the signature.

gpg --keyid-format long --verify SHA256SUMS.gpg SHA256SUMS

This time the command should return something like this:

gpg: Signature made Fri 25 Mar 04:36:20 2016 GMT
                    using DSA key ID 46181433FBB75451
gpg: Good signature from "Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: C598 6B4F 1257 FFA8 6632  CBA7 4618 1433 FBB7 5451
gpg: Signature made Fri 25 Mar 04:36:20 2016 GMT
                    using RSA key ID D94AA3F0EFE21092
gpg: Good signature from "Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 8439 38DF 228D 22F7 B374  2BC0 D94A A3F0 EFE2 1092

A Good signature means that the checked file was definitely signed by the owner of the keyfile stated (if they didn’t match, the signature would be reported as BAD). The warning message is simply there to let you know that you have not countersigned the key and it isn’t in your list of trusted sources. If you want to know more about signing keys and trust, you can check out the Ubuntu community GPG wiki page.

Now that we have verified the checksum file was created by Ubuntu, we can check that the ISO file we downloaded matches the checksum.

Check the ISO

Duration: 0:02

Now you need to generate a sha256 checksum for the downloaded ISO and compare it to the one you downloaded in your SHA256SUM file.

Make sure the downloaded the SHA256SUMS and SHA256SUMS.gpg files are in the same directory as the Ubuntu ÌSO file. Then run the following commands in a terminal.

sha256sum -c SHA256SUMS 2>&1 | grep OK

The output you want will look similar to the following:

ubuntu-18.04-desktop-amd64.iso: OK

If you get no results (or any result other than that shown above) then the ISO file does not match the checksum. This could be because the ISO has been altered, or it downloaded incorrectly - either way you should download a fresh ISO from a known good source.

What’s next?

Now you know you have a good ISO image, you can burn it to a DVD or copy it to a bootable USB stick to install or try Ubuntu!

Here are a few more tutorials you may want to look at:

Finding help

If you get stuck, help is always at hand.

2 Likes

Hello! Looking to get in touch with the author of this tutorial, or someone who knows about its copyright. Thanks in advance from the Ubuntu MATE team!

@madhens The tutorials here were imported from the old tutorials.u.c codebase. By checking the Git log you’ll find authorship information.

1 Like

The “| grep OK” part seems to make things not work on Portuguese, since in portuguese when the ISO is OK, the command actually display the word SUCESSO (which means sucess). This problem may happen in other languages too.

Maybe the tutorial should put the command only as:

sha256sum -c SHA256SUMS 2>&1

I have found 1 main issue with this guide. Because of this I was not able to verify my ISO using this guide. I had to google for help.
This command did not work for me:
gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x46181433FBB75451 0xD94AA3F0EFE21092
I had to put number “80” after address like this:
gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x46181433FBB75451 0xD94AA3F0EFE21092
For Linux beginners like me it was big deal with lot of cursing till I found what’s wrong. But I understand Linux is free open source software. I just trying to help improve this guide to save other beginners.

There is also one confusing thing:
By following step " If you don’t have the keys…" I did not get this:
gpg: Signature made Thu Apr 5 22:19:36 2018 EDT using DSA key ID 46181433FBB75451 gpg: Can't check signature: No public key gpg: Signature made Thu Apr 5 22:19:36 2018 EDT using RSA key ID D94AA3F0EFE21092 gpg: Can't check signature: No public key

But instead I just got one of the two keys (second one).
I hope the guide will be repaired. My OS from which I followed the guide: “Linux Mint 19.3”

md5sum --version
sha256sum --version

These commands do nothing. I am on Windows. Installed gpg4win. So i have gpg.

Also tested on Linux.

I get message:

gpg: Note: '--version' is not considered an option
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
usage: gpg [options] [filename]

I tried:

gpg md5sum --version

Or launch gpg and then write:

md5sum --version

Facing same problem using:

sha256sum --version

I ran that as root in Linux and as admin in Windows!

Also didn’t find anything about these commands even on gpg4win and google found nothing! Strange!

Change suggestion:
http://releases.ubuntu.com/bionic/ -> http://releases.ubuntu.com/focal/

1 Like

Or to avoid having to change URL each release, we could simply change ‘current’ to ‘18.04 (Bionic Beaver)’.

for the 18.04 (Bionic Beaver) version of Ubuntu

A post was split to a new topic: Is Ubuntu vulnerable to fake keys?

Hi, I downloaded Ubuntu Studio 21.04 Live DVD & it won’t boot. I ran the checksum, and it won’t verify the download. Tried a few times. The instructions for verification need a section on how to notify Ubuntu (or derivatives) if the checksum & the iso are corrupted or invalid.

You seem to be stuck, which is what the “Finding Help” section of the tutorial is for.

1 Like

md5sum --version
sha256sum --version

In Windows Powershell (all versions), you can use Get-FileHash to get the hashes.

Would be useful to be able to see the whole tutorial on one page as it’s displayed here!

Thanks for joining the community! I’ll bring this up during our next talk with the design team, if there would be a way to have a single-page option for tutorials. Is it this tutorial only, or are there others that you also think are useful to have in a single-page version?

New to this whole thing. I just followed the instructions to verify my 2022.04 download and when I clicked on the SHA256SUMS link it took me to a page with the sums as text. I copied the text to a document, saved it as SHA256SUMS and used that, but it gave me a Bad signature. I went back and right clicked the SHA256Sums link and used the Save link as… option which gave me a Good signature. Is it worth adding a comment like “Do not copy their content, use “right-click->Save Link As…” to download the files themselves”?

Quote lifted from the Mint forums

https://linuxmint-guides.linuxsecrets.com/en/latest/verify.html

I use Mint, so I checked there. As one other Mint using commenter mentions above, I only got one key (RSA). Perhaps not so significant???

Three suggestions for improvement:

md5sum should no longer be used. Ubuntu no longer provides md5sums for releases.

The DSA-1 key

46181433FBB75451

should be no longer in use, because DSA-1 is considered weak for several years now. Please ensure any currently used keys are listed. If possible, add a note on where users can check for them in case of future changes.

While the “long” key ID format is being used here, this is no longer sufficient to uniquely identify a GPG key. Please use the full key fingerprint when referring to keys. Also, transfer of the key material should ideally take place over a transport encrypted connection (HKPS) when trust is to be bestowed / inherited.

For example,

gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x46181433FBB75451 0xD94AA3F0EFE21092

should actually say

gpg --keyid-format long --keyserver hkps://keyserver.ubuntu.com --recv-keys 0xC5986B4F1257FFA86632CBA746181433FBB75451 0x843938DF228D22F7B3742BC0D94AA3F0EFE21092
3 Likes

Could you please provide alternate steps to obtain the public GPG keys which don’t rely on “hkp://”? My organisation’s proxy only allows me http/https access to the internet.

The specific command I need to work around is:
gpg --keyid-format long --keyserver hkp://keyserver.ubuntu.com --recv-keys 0x46181433FBB75451 0xD94AA3F0EFE21092

Thank you!

The following check command ( visible on https://ubuntu.com/tutorials/how-to-verify-ubuntu#6-check-the-iso ) Must be change :
sha256sum -c SHA256SUMS 2>&1 | grep OK

SINCE the PATTERN “OK” appear only in ENGLISH TERMINAL.
Keep only the minimum command length for portability
KISS: Keep it Simple and Stupid

sha256sum -c SHA256SUMS

You may wonder how many users gave up at this stage, for this kind of silly reason…

FYI, until I removed the –keyid-format long option from all the gpg commands in this article, the –verify kept giving me the error:
$ gpg: BAD signature from “Ubuntu CD Image Automatic Signing Key (2012) cdimage@ubuntu.com” [unknown]
After re-running all previous commands without that option, I ran:
$ gpg --verify SHA256SUMS.gpg SHA256SUMS
and got:
gpg: Good signature from “Ubuntu CD Image Automatic Signing Key (2012) cdimage@ubuntu.com” [unknown]