W: GPG error: The following signatures couldn't be verified because the public key is not available [duplicate]

On my Ubuntu 14.04, I followed http://mirror.its.dal.ca/cran/bin/linux/ubuntu/README to add the following to /etc/apt/sources.list

deb http://stat.ethz.ch/CRAN/bin/linux/ubuntu trusty/

When I run sudo apt-get update, I get this error

W: GPG error: http://stat.ethz.ch trusty/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

The whole output is at the end of this post. I wonder what the problem means and how to solve it? Thanks!

$ sudo apt-get update
Ign http://us.archive.ubuntu.com trusty InRelease
Ign http://us.archive.ubuntu.com trusty-updates InRelease                      
Ign http://dl.google.com stable InRelease                                      
Ign http://us.archive.ubuntu.com trusty-backports InRelease                    
Ign http://security.ubuntu.com trusty-security InRelease                       
Hit http://us.archive.ubuntu.com trusty Release.gpg                            
Hit http://security.ubuntu.com trusty-security Release.gpg                     
Hit http://us.archive.ubuntu.com trusty-updates Release.gpg                    
Ign http://dl.google.com stable InRelease                                      
Hit http://us.archive.ubuntu.com trusty-backports Release.gpg                  
Hit http://security.ubuntu.com trusty-security Release                         
Hit http://dl.google.com stable Release.gpg                                    
Hit http://us.archive.ubuntu.com trusty Release                                
Hit http://us.archive.ubuntu.com trusty-updates Release                        
Hit http://security.ubuntu.com trusty-security/main Sources                    
Ign http://extras.ubuntu.com trusty InRelease                                  
Hit http://dl.google.com stable Release.gpg                                    
Hit http://us.archive.ubuntu.com trusty-backports Release                      
Ign http://archive.canonical.com trusty InRelease                              
Hit http://security.ubuntu.com trusty-security/restricted Sources              
Hit http://us.archive.ubuntu.com trusty/main Sources                           
Hit http://dl.google.com stable Release                                        
Hit http://us.archive.ubuntu.com trusty/restricted Sources                     
Hit http://security.ubuntu.com trusty-security/universe Sources                
Hit http://us.archive.ubuntu.com trusty/universe Sources                       
Hit http://security.ubuntu.com trusty-security/multiverse Sources              
Hit http://security.ubuntu.com trusty-security/main amd64 Packages             
Hit http://dl.google.com stable Release                                        
Hit http://us.archive.ubuntu.com trusty/multiverse Sources                     
Hit http://extras.ubuntu.com trusty Release.gpg                                
Hit http://security.ubuntu.com trusty-security/restricted amd64 Packages       
Hit http://us.archive.ubuntu.com trusty/main amd64 Packages                    
Ign http://archive.canonical.com trusty InRelease                              
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages         
Hit http://us.archive.ubuntu.com trusty/restricted amd64 Packages              
Hit http://dl.google.com stable/main amd64 Packages                            
Hit http://security.ubuntu.com trusty-security/multiverse amd64 Packages       
Hit http://us.archive.ubuntu.com trusty/universe amd64 Packages                
Ign http://stat.ethz.ch trusty/ InRelease                                      
Hit http://security.ubuntu.com trusty-security/main i386 Packages              
Hit http://us.archive.ubuntu.com trusty/multiverse amd64 Packages              
Hit http://dl.google.com stable/main i386 Packages                             
Hit http://security.ubuntu.com trusty-security/restricted i386 Packages        
Hit http://us.archive.ubuntu.com trusty/main i386 Packages                     
Hit http://us.archive.ubuntu.com trusty/restricted i386 Packages               
Hit http://security.ubuntu.com trusty-security/universe i386 Packages          
Hit http://extras.ubuntu.com trusty Release                                    
Hit http://archive.canonical.com trusty Release.gpg                            
Hit http://security.ubuntu.com trusty-security/multiverse i386 Packages        
Hit http://security.ubuntu.com trusty-security/main Translation-en             
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en       
Hit http://us.archive.ubuntu.com trusty/universe i386 Packages                 
Hit http://security.ubuntu.com trusty-security/restricted Translation-en       
Get:1 http://stat.ethz.ch trusty/ Release.gpg [490 B]                          
Hit http://dl.google.com stable/main amd64 Packages                            
Hit http://us.archive.ubuntu.com trusty/multiverse i386 Packages               
Hit http://archive.canonical.com trusty Release.gpg                            
Hit http://extras.ubuntu.com trusty/main Sources                               
Hit http://dl.google.com stable/main i386 Packages                             
Hit http://us.archive.ubuntu.com trusty/main Translation-en                    
Hit http://security.ubuntu.com trusty-security/universe Translation-en         
Hit http://us.archive.ubuntu.com trusty/multiverse Translation-en              
Hit http://stat.ethz.ch trusty/ Release                                        
Ign http://stat.ethz.ch trusty/ Release                                        
Hit http://extras.ubuntu.com trusty/main amd64 Packages                        
Hit http://us.archive.ubuntu.com trusty/restricted Translation-en              
Hit http://archive.canonical.com trusty Release                                
Hit http://us.archive.ubuntu.com trusty/universe Translation-en                
Hit http://us.archive.ubuntu.com trusty-updates/main Sources                   
Hit http://extras.ubuntu.com trusty/main i386 Packages                         
Hit http://us.archive.ubuntu.com trusty-updates/restricted Sources             
Hit http://archive.canonical.com trusty Release                                
Hit http://us.archive.ubuntu.com trusty-updates/universe Sources               
Ign http://stat.ethz.ch trusty/ Packages/DiffIndex                             
Hit http://us.archive.ubuntu.com trusty-updates/multiverse Sources             
Hit http://us.archive.ubuntu.com trusty-updates/main amd64 Packages            
Hit http://us.archive.ubuntu.com trusty-updates/restricted amd64 Packages      
Hit http://us.archive.ubuntu.com trusty-updates/universe amd64 Packages        
Hit http://archive.canonical.com trusty/partner Sources                        
Hit http://us.archive.ubuntu.com trusty-updates/multiverse amd64 Packages      
Hit http://us.archive.ubuntu.com trusty-updates/main i386 Packages             
Ign https://private-ppa.launchpad.net precise InRelease                        
Hit http://archive.canonical.com trusty/partner amd64 Packages                 
Hit http://us.archive.ubuntu.com trusty-updates/restricted i386 Packages       
Hit http://us.archive.ubuntu.com trusty-updates/universe i386 Packages         
Hit http://us.archive.ubuntu.com trusty-updates/multiverse i386 Packages       
Hit http://us.archive.ubuntu.com trusty-updates/main Translation-en            
Hit https://private-ppa.launchpad.net precise Release.gpg                      
Hit http://us.archive.ubuntu.com trusty-updates/multiverse Translation-en      
Hit http://us.archive.ubuntu.com trusty-updates/restricted Translation-en      
Hit http://archive.canonical.com trusty/partner i386 Packages                  
Hit http://us.archive.ubuntu.com trusty-updates/universe Translation-en        
Hit http://us.archive.ubuntu.com trusty-backports/main Sources                 
Hit http://us.archive.ubuntu.com trusty-backports/restricted Sources           
Hit http://us.archive.ubuntu.com trusty-backports/universe Sources             
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Sources           
Hit http://stat.ethz.ch trusty/ Packages                                       
Hit https://private-ppa.launchpad.net precise Release                          
Hit http://us.archive.ubuntu.com trusty-backports/main amd64 Packages          
Hit http://us.archive.ubuntu.com trusty-backports/restricted amd64 Packages    
Hit http://us.archive.ubuntu.com trusty-backports/universe amd64 Packages      
Hit http://us.archive.ubuntu.com trusty-backports/multiverse amd64 Packages    
Hit http://us.archive.ubuntu.com trusty-backports/main i386 Packages           
Hit http://us.archive.ubuntu.com trusty-backports/restricted i386 Packages     
Ign http://dl.google.com stable/main Translation-en_US                         
Hit http://archive.canonical.com trusty/partner Sources                        
Hit https://private-ppa.launchpad.net precise/main amd64 Packages              
Ign http://dl.google.com stable/main Translation-en                            
Hit http://us.archive.ubuntu.com trusty-backports/universe i386 Packages       
Ign http://dl.google.com stable/main Translation-en_US                         
Hit http://us.archive.ubuntu.com trusty-backports/multiverse i386 Packages     
Hit http://us.archive.ubuntu.com trusty-backports/main Translation-en          
Hit http://archive.canonical.com trusty/partner amd64 Packages                 
Hit https://private-ppa.launchpad.net precise/main i386 Packages               
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Translation-en    
Ign http://dl.google.com stable/main Translation-en                            
Hit http://us.archive.ubuntu.com trusty-backports/restricted Translation-en    
Hit http://us.archive.ubuntu.com trusty-backports/universe Translation-en      
Hit http://archive.canonical.com trusty/partner i386 Packages                  
Ign http://extras.ubuntu.com trusty/main Translation-en_US                     
Ign http://us.archive.ubuntu.com trusty/main Translation-en_US                 
Ign http://us.archive.ubuntu.com trusty/multiverse Translation-en_US           
Ign http://us.archive.ubuntu.com trusty/restricted Translation-en_US           
Ign http://extras.ubuntu.com trusty/main Translation-en                        
Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US             
Ign http://archive.canonical.com trusty/partner Translation-en                 
Ign http://stat.ethz.ch trusty/ Translation-en_US                   
Ign http://archive.canonical.com trusty/partner Translation-en
Ign http://stat.ethz.ch trusty/ Translation-en
Ign https://private-ppa.launchpad.net precise/main Translation-en_US
Ign https://private-ppa.launchpad.net precise/main Translation-en
Fetched 490 B in 6s (78 B/s)                                                   
Reading package lists... Done
W: GPG error: http://stat.ethz.ch trusty/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

Solution 1:

See the README file:

SECURE APT

The Ubuntu archives on CRAN are signed with the key of "Michael Rutter <[email protected]>" with key ID E084DAB9. To add the key to your system with one command use (thanks to Brett Presnell for the tip):

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

An alternate method can be used by retrieving the key with

gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9

and then feed it to apt-key with

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