Installing R from CRAN Ubuntu repository: No Public Key Error

LinuxRApt

Linux Problem Overview


I am on R version 2.13 and would like to update to a newer version in order to use some packages that depend on R>= 2.14.

I have the line to my sources.list file as found described here. I then navigate to the terminal and type:

sudo apt-get update

and get the following error when trying to update R on the CRAN mirror closest to me:

>Reading package lists... Done > W: GPG error: http://lib.stat.cmu.edu oneiric/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

Any idea how to debug this error?

Linux Solutions


Solution 1 - Linux

The simplest solution that worked for me was from Emre Sahin in this thread:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 

Solution 2 - Linux

Like @Ben Bolker commented (sorry I hijacked your commented, but the correct answer was not yet posted), in [the description][1] of the debian package repo there is a section secure apt which says:

> SECURE APT > > The Debian backports archives on CRAN are signed with the key of > "Johannes Ranke (CRAN Debian archive) <[email protected]>" with key > ID 381BA480. You can fetch this with > > gpg --keyserver subkeys.pgp.net --recv-key 381BA480 or > alternatively, using another key server, > > gpg --keyserver pgp.mit.edu --recv-key 381BA480 If this doesn't > work, it might be due to a firewall blocking port 11371. > Alternatively, you can search for 0x381BA480 at > http://keyserver.noreply.org/ or http://pgp.mit.edu/ and copy the key block into a plain text > file, named, for instance, jranke_cran.asc. > > If receiving the key with gpg did work, you need to export it to a > text file > > gpg -a --export 381BA480 > jranke_cran.asc In both cases you need > to make the key known to the apt system by running > > apt-key add jranke_cran.asc as root.

If you have not already done this, this will probably fix your issue. [1]: http://cran.r-project.org/bin/linux/debian/

Solution 3 - Linux

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID

and replace KEYID with the number shown in the error message.

Solution 4 - Linux

Thanks to Philipp Burckhardt, I got it fixed.

Try this:

gpg --keyserver pgpkeys.mit.edu --recv-key 51716619E084DAB9  
gpg -a --export 51716619E084DAB9 | sudo apt-key add -

Solution 5 - Linux

Here is a step-by-step answer that might be easier to follow.

  1. Fetch the key (the last 8 digits in the warning message):

     gpg --keyserver pgp.mit.edu --recv-key E084DAB9
    

The output should look like this:

    gpg: requesting key E084DAB9 from hkp server pgp.mit.edu
    gpg: key E084DAB9: public key "Michael Rutter <[email protected]>" imported
    gpg: Total number processed: 1
    gpg:               imported: 1  (RSA: 1)

2. Add the key (superuser access required):

    gpg -a --export E084DAB9 | sudo apt-key add -

4. Update the repositories:

    sudo apt-get update

There should be no warning about the missing key now.

Solution 6 - Linux

I encountered the same issue and the only solution I found, perhaps due to a firewall, was to use the helpful Y PPA Manager. The two steps below outline has worked on Ubuntu 15.04.

  1. First install the Y PPA Manager:

    sudo add-apt-repository ppa:webupd8team/y-ppa-manager sudo apt-get update sudo apt-get install y-ppa-manager

  2. Then fetch missing keys by running the Y PPA Manager:

    y-ppa-manager

> Click "Advanced" >> Next, click "Try to import missing GPG keys"

Finally, update again to check if it works:

sudo apt-get update

Solution 7 - Linux

Much like others posted above, this one-liner seems to work well on Debian 6:

sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 381BA480

Executing: gpg --ignore-time-conflict --no-options
--no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys 381BA480 
gpg: requesting key 381BA480 from hkp server pgp.mit.edu 
gpg: key 381BA480: public key "Johannes Ranke (CRAN Debian archive) <[email protected]>" imported 
gpg: no ultimately trusted keys found 
gpg: Total number processed: 1 
gpg:      imported: 1

Solution 8 - Linux

This solved my problem

$ wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add

Solution 9 - Linux

It had to use a longer identifier for the key.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

The issue seems to be a duplicated key ID on the server. See the instructions from the CRAN and more background info on this post by Michael Rutter.

Solution 10 - Linux

The easiest fix is to simply follow the instructions from https://cran.r-project.org/bin/linux/ubuntu/. Run this as sudo:

# update indices
apt update -qq
# install two helper packages we need
apt install --no-install-recommends software-properties-common dirmngr
# add the signing key (by Michael Rutter) for these repos
# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 
# Fingerprint: 298A3A825C0D65DFD57CBB651716619E084DAB9
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBtibert3View Question on Stackoverflow
Solution 1 - LinuxanonView Answer on Stackoverflow
Solution 2 - LinuxPaul HiemstraView Answer on Stackoverflow
Solution 3 - LinuxSaurabh Chandra PatelView Answer on Stackoverflow
Solution 4 - LinuxpetermeissnerView Answer on Stackoverflow
Solution 5 - LinuxDenisView Answer on Stackoverflow
Solution 6 - LinuxTollan RennerView Answer on Stackoverflow
Solution 7 - LinuxRobert CaseyView Answer on Stackoverflow
Solution 8 - LinuxSam KihikaView Answer on Stackoverflow
Solution 9 - Linuxgui11aumeView Answer on Stackoverflow
Solution 10 - LinuxpetrovskiView Answer on Stackoverflow