RASPBIAN JESSIE LITEでapt-get updateでGPG errorが発生した時の対処法

[https://www.raspberrypi.org/downloads/raspbian/](https://www.raspberrypi.org/downloads/raspbian/)からRaspbianをダウンロードしてmicroSDに焼いてRaspberry Pi 3で動かしました。

RASPBIAN JESSIE LITE

- Version:May 2016
- Release date:2016-05-27
- Kernel version:4.4
  
```bash:bash
sudo apt-get update
```
を実行すると

```
Hit http://mirrordirector.raspbian.org jessie InRelease                        
Get:1 http://www.linux-projects.org wheezy InRelease [1,169 B]                 
Hit http://archive.raspberrypi.org jessie InRelease
Ign http://www.linux-projects.org wheezy InRelease
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages       
Hit http://archive.raspberrypi.org jessie/main armhf Packages                  
Hit http://archive.raspberrypi.org jessie/ui armhf Packages                    
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages          
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages               
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB               
Ign http://archive.raspberrypi.org jessie/main Translation-en                  
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB                 
Ign http://archive.raspberrypi.org jessie/ui Translation-en                    
Hit http://www.linux-projects.org wheezy/main armhf Packages                   
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB        
Ign http://www.linux-projects.org wheezy/main Translation-en_GB                
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en           
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB           
Ign http://mirrordirector.raspbian.org jessie/main Translation-en              
Ign http://www.linux-projects.org wheezy/main Translation-en                   
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB       
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en          
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB            
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en               
Fetched 1,169 B in 14s (79 B/s)                                                
Reading package lists... Done
W: GPG error: http://www.linux-projects.org wheezy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 99DA5D2AFCE635A4
```
最後の行で
`W: GPG error: http://www.linux-projects.org wheezy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 99DA5D2AFCE635A4`
というエラーが表示されてしまいました。  
  
[http://ccm.net/faq/809-debian-apt-get-no-pubkey-gpg-error](http://ccm.net/faq/809-debian-apt-get-no-pubkey-gpg-error)を参考にしてgpgコマンドを試してみます。参考サイトによると、`--recv-key`のパラメーターにはエラーに表示されている数値を使うらしいです。今回は`99DA5D2AFCE635A4`ですね。

```bash:bash
gpg --keyserver pgpkeys.mit.edu --recv-key 99DA5D2AFCE635A4
```

```
gpg: directory `/home/pi/.gnupg' created
gpg: new configuration file `/home/pi/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/pi/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/pi/.gnupg/secring.gpg' created
gpg: keyring `/home/pi/.gnupg/pubring.gpg' created
gpg: requesting key FCE635A4 from hkp server pgpkeys.mit.edu
gpg: /home/pi/.gnupg/trustdb.gpg: trustdb created
gpg: key FCE635A4: public key "Luca Risolia <luca.risolia@studio.unibo.it>" imported
gpg: Total number processed: 1
gpg:               imported: 1
```
```bash:bash
gpg -a --export 99DA5D2AFCE635A4 | sudo apt-key add -
```
```
OK
```

再び`update`してみます。

```bash:bash
sudo apt-get update
```
```
Hit http://mirrordirector.raspbian.org jessie InRelease                        
Hit http://archive.raspberrypi.org jessie InRelease                            
Get:1 http://www.linux-projects.org wheezy InRelease [1,169 B]
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Get:2 http://www.linux-projects.org wheezy/main armhf Packages [2,700 B]       
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages           
Hit http://archive.raspberrypi.org jessie/ui armhf Packages                    
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages  
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB               
Ign http://archive.raspberrypi.org jessie/main Translation-en                  
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB                 
Ign http://archive.raspberrypi.org jessie/ui Translation-en                    
Ign http://www.linux-projects.org wheezy/main Translation-en_GB                
Ign http://www.linux-projects.org wheezy/main Translation-en                   
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB        
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en           
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB           
Ign http://mirrordirector.raspbian.org jessie/main Translation-en              
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB       
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en          
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB            
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en               
Fetched 3,869 B in 12s (305 B/s)                                               
Reading package lists... Done
```
  
やったぜ。