labunix's blog

labunixのラボUnix

UbuntuのGnuPG鍵を検索する

■UbuntuのGnuPG鍵を検索する。

 Ubuntuの日本語環境
 http://www.ubuntulinux.jp/japanese

■wgetrcや/etc/profile.d/proxy.shでプロキシの設定は行っているものとする。

$ grep _proxy /etc/wgetrc
#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/
#use_proxy = on

$ echo $http_proxy
http://192.168.1.1:3128/

■検索するにも「Key ID」が分からないので、対象のGPG鍵を確認。

$ w3m -dump -o http_proxy=$http_proxy http://www.ubuntulinux.jp/japanese 2>/dev/null | \
  grep "wget \-q" | awk '{print $3}' | sort -u
https://www.ubuntulinux.jp/ubuntu-ja-archive-keyring.gpg
https://www.ubuntulinux.jp/ubuntu-jp-ppa-keyring.gpg

■GPG鍵の保存

$ w3m -dump -o http_proxy=$http_proxy http://www.ubuntulinux.jp/japanese 2>/dev/null | \
  grep "wget \-q" | awk '{print $3}' | sort -u | wget -i -

■ASCIIだと以下の表示。

$ echo "Hello World" | tee test
Hello World
$ file test
test: ASCII text

■バイナリデータなので、一度取り込むしかない。

$ file ubuntu-j*
ubuntu-ja-archive-keyring.gpg: GPG key public ring
ubuntu-jp-ppa-keyring.gpg:     data

■取り込み

$ gpg --import ubuntu-j*
gpg: 鍵0C4ECFEC: 公開鍵“Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>”を読み込みました
gpg: 鍵CDC1D865:“Launchpad PPA for Ubuntu Japanese Team”変更なし
gpg:     処理数の合計: 2
gpg:           読込み: 1
gpg:         変更なし: 1

■第三者サーバとして「pgp.mit.edu」で検索

$ gpg --keyserver pgp.mit.edu --keyserver-options http_proxy=$http_proxy --search-keys 0C4ECFEC
gpg: “0C4ECFEC”をhkpサーバーpgp.mit.eduから検索
(1)     Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>
          1024 bit DSA key 0C4ECFEC, 作成: 2005-05-24
Keys 1-1 of 1 for "0C4ECFEC".  番号(s)、N)次、またはQ)中止を入力してください >Q

$ gpg --keyserver pgp.mit.edu --keyserver-options http_proxy=$http_proxy --search-keys CDC1D865
gpg: “CDC1D865”をhkpサーバーpgp.mit.eduから検索
(1)     Launchpad PPA for Ubuntu Japanese Team
          1024 bit RSA key CDC1D865, 作成: 2009-04-05
Keys 1-1 of 1 for "CDC1D865".  番号(s)、N)次、またはQ)中止を入力してください >Q

$ gpg --delete-keys archive@ubuntulinux.jp
gpg (GnuPG) 1.4.12; Copyright (C) 2012 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

■秘密鍵、公開鍵、署名、フィンガープリントの順に確認
 ※当然ながら秘密鍵は得られない。

$ gpg --list-secret-keys 0C4ECFEC CDC1D865
gpg: error reading key: 秘密鍵が得られません

$ gpg --list-key 0C4ECFEC CDC1D865
pub   1024R/CDC1D865 2009-04-05
uid                  Launchpad PPA for Ubuntu Japanese Team

pub   1024D/0C4ECFEC 2005-05-24
uid                  Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>
sub   2048g/40A3E9B2 2005-05-24

$ gpg --list-sig 0C4ECFEC CDC1D865
pub   1024R/CDC1D865 2009-04-05
uid                  Launchpad PPA for Ubuntu Japanese Team
sig 3        CDC1D865 2009-04-05  Launchpad PPA for Ubuntu Japanese Team

pub   1024D/0C4ECFEC 2005-05-24
uid                  Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>
sig 3        0C4ECFEC 2005-05-24  Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>
sub   2048g/40A3E9B2 2005-05-24
sig          0C4ECFEC 2005-05-24  Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>

$ gpg --fingerprint 0C4ECFEC CDC1D865
pub   1024R/CDC1D865 2009-04-05
                 指紋 = 5967 6CBC F5DF D8C1 CEFE  375B 68B5 F60D CDC1 D865
uid                  Launchpad PPA for Ubuntu Japanese Team

pub   1024D/0C4ECFEC 2005-05-24
                 指紋 = 3B59 3C7B E6DB 6A89 FB7C  BFFD 058A 05E9 0C4E CFEC
uid                  Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>
sub   2048g/40A3E9B2 2005-05-24

■削除する場合

$ gpg --delete-keys 0C4ECFEC CDC1D865
gpg (GnuPG) 1.4.12; Copyright (C) 2012 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


pub  1024D/0C4ECFEC 2005-05-24 Ubuntu-ja Archive Automatic Signing Key <archive@ubuntulinux.jp>

この鍵を鍵輪から削除しますか? (y/N) y

pub  1024R/CDC1D865 2009-04-05 Launchpad PPA for Ubuntu Japanese Team

この鍵を鍵輪から削除しますか? (y/N) y