目次: apt
Packagesには各Debianパッケージのハッシュ値が記述されていて、悪意ある者がDebianパッケージを改変しても検知できるようになっています。ReleaseにはPackagesのハッシュ値が記述されていて、Packagesを改変されても検知できるようになっています。
Releaseの改変に対しては、サーバーの作成者が署名を付け、Releaseが作成時から改変されていないことを保証します。
パッケージ(*.deb) <--(ハッシュ値)-- Packages <--(ハッシュ値)-- Release <--(署名)-- InReleaseもしくはRelease.gpg
保証の関係を図示すると上記のとおりです。前回のapt-get updateのエラーメッセージはInReleaseもしくはRelease.gpgが存在しない、もしくは、あっても信頼できない署名だと言って怒っているのです。
最初からapt-getに信頼されている鍵は公式サーバーが使っている鍵ですが、当然ながら私は知りません。ですので、
という手順を取ります。
# gpg --gen-key gpg (GnuPG) 2.2.12; Copyright (C) 2018 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. Note: Use "gpg --full-generate-key" for a full featured key generation dialog. GnuPG needs to construct a user ID to identify your key. Real name: ...
名前やメールアドレスを聞かれるので適宜答えてください。途中でパスフレーズを聞かれます。今回はテストなので、名前はTest User、パスフレーズはabcd1234にしました。
自作した鍵をaptに信用してもらうには、公開鍵(秘密鍵ではありません)をaptの信頼済み鍵束に登録します。
# gpg --list-keys /root/.gnupg/pubring.kbx ------------------------ pub rsa3072 2019-08-11 [SC] [expires: 2021-08-10] A24D479395FF7F2B4A787D29439D445DCA4AF8F6 ★このIDを指定する uid [ultimate] Test User sub rsa3072 2019-08-11 [E] [expires: 2021-08-10] # mkdir /var/www/linux/debian/gpg # gpg --export A24D479395FF7F2B4A787D29439D445DCA4AF8F6 > /var/www/linux/debian/gpg/public.key # curl http://192.168.1.1/linux/debian/gpg/public.key | apt-key add - # apt-key list /etc/apt/trusted.gpg -------------------- pub rsa3072 2019-08-11 [SC] [expires: 2021-08-10] A24D 4793 95FF 7F2B 4A78 7D29 439D 445D CA4A F8F6 ★自作の鍵が追加された uid [ unknown] Test User sub rsa3072 2019-08-11 [E] [expires: 2021-08-10] /etc/apt/trusted.gpg.d/debian-archive-buster-automatic.gpg ---------------------------------------------------------- pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12] 80D1 5823 B7FD 1561 F9F7 BCDD DC30 D7C2 3CBB ABEE uid [ unknown] Debian Archive Automatic Signing Key (10/buster) <ftpmaster@debian.org> sub rsa4096 2019-04-14 [S] [expires: 2027-04-12] /etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.gpg ------------------------------------------------------------------- pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12] 5E61 B217 265D A980 7A23 C5FF 4DFA B270 CAA9 6DFA uid [ unknown] Debian Security Archive Automatic Signing Key (10/buster) <ftpmaster@debian.org> sub rsa4096 2019-04-14 [S] [expires: 2027-04-12] ...
自分で作った鍵ペアのうち、公開鍵をgpg --exportでファイルにエクスポートし、HTTPサーバーに配置します。公開鍵ファイルをapt-key addで信頼済みの鍵束に追加します。
今回作成した鍵はテストが終わったら不要なのでapt-key del ’キーID’ で削除してください。apt-key listで出てきたキーIDをコピペすれば良いです(スペースもそのまま入れてOK)。
最後にReleaseファイルに署名します。Releaseファイルの署名には2種類あって、署名をReleaseファイルと一緒に書くInReleaseファイルと、署名だけを別に書くRelease.gpgファイルがあります。
InReleaseだけ作成すれば機能するようですが、とりあえず両方の作り方を紹介しておきます。
### GnuPGでReleaseファイルに署名
# echo -n "abcd1234" | gpg --batch --passphrase-fd 0 --pinentry-mode loopback --clearsign -o InRelease Release
# echo -n "abcd1234" | gpg --batch --passphrase-fd 0 --pinentry-mode loopback -abs -o Release.gpg Release
# chmod 644 Release InRelease Release.gpg
署名が完了したらapt-get updateしてみましょう。
# apt-get update Get:1 http://192.168.1.1/linux/debian buster InRelease [3941 B] Hit:2 http://ftp.jp.debian.org/debian testing InRelease Get:3 http://192.168.1.1/linux/debian buster/stable amd64 Packages [1752 B] Get:4 http://192.168.1.1/linux/debian buster/stable amd64 Contents (deb) [1242 B] Fetched 6935 B in 0s (25.7 kB/s) Reading package lists... Done
うまくいきました。apt-get install docker-ceを実行すると、、、
# apt-get install docker-ce Reading package lists... Done Building dependency tree Reading state information... Done Package docker-ce is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: docker-ce-cli E: Package 'docker-ce' has no installation candidate
どうやら依存関係を無視してDockerのパッケージを1つしか登録しなかったため、依存関係のエラーが出てしまったようです。
他のパッケージ(docker-ce_cli, container.io)もダウンロードしましょう。pool/stable/amd64の下に追加し、apt-ftparchiveと署名をやり直します。
linux |-- conf | |-- apt_generate_debian_buster.conf | `-- apt_release_debian_buster.conf `-- debian |-- dists | `-- buster | |-- InRelease | |-- Release | |-- Release.gpg | |-- packages-amd64.db | |-- pool | | `-- stable | | `-- amd64 | | |-- containerd.io_1.2.6-3_amd64.deb | | |-- docker-ce-cli_19.03.1~3-0~debian-buster_amd64.deb | | `-- docker-ce_19.03.1~3-0~debian-buster_amd64.deb | `-- stable | |-- Contents-amd64 | |-- Contents-amd64.bz2 | |-- Contents-amd64.gz | `-- binary-amd64 | |-- Packages | |-- Packages.bz2 | `-- Packages.gz `-- gpg `-- public.key 10 directories, 16 files
以上のようなディレクトリ構成になるはずです。もう一度apt-get install docker-ceしてみましょう。
# apt-get install docker-ce Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: aufs-dkms aufs-tools cgroupfs-mount containerd.io docker-ce-cli Suggested packages: aufs-dev The following NEW packages will be installed: aufs-dkms aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/88.0 MB of archives. After this operation, 390 MB of additional disk space will be used. Do you want to continue? [Y/n] Selecting previously unselected package aufs-dkms. (Reading database ... 325385 files and directories currently installed.) Preparing to unpack .../0-aufs-dkms_4.19+20190211-1_all.deb ... Unpacking aufs-dkms (4.19+20190211-1) ... Selecting previously unselected package aufs-tools. Preparing to unpack .../1-aufs-tools_1%3a4.14+20190211-1_amd64.deb ... Unpacking aufs-tools (1:4.14+20190211-1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../2-cgroupfs-mount_1.4_all.deb ... Unpacking cgroupfs-mount (1.4) ... Selecting previously unselected package containerd.io. Preparing to unpack .../3-containerd.io_1.2.6-3_amd64.deb ... Unpacking containerd.io (1.2.6-3) ... Selecting previously unselected package docker-ce-cli. Preparing to unpack .../4-docker-ce-cli_5%3a19.03.1~3-0~debian-buster_amd64.deb ... Unpacking docker-ce-cli (5:19.03.1~3-0~debian-buster) ... Selecting previously unselected package docker-ce. Preparing to unpack .../5-docker-ce_5%3a19.03.1~3-0~debian-buster_amd64.deb ... Unpacking docker-ce (5:19.03.1~3-0~debian-buster) ... Setting up aufs-tools (1:4.14+20190211-1) ... Setting up containerd.io (1.2.6-3) ... Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service -> /lib/systemd/system/containerd.service. Setting up docker-ce-cli (5:19.03.1~3-0~debian-buster) ... Setting up aufs-dkms (4.19+20190211-1) ... Loading new aufs-4.19+20190211 DKMS files... Building for 4.19.0-5-amd64 Building initial module for 4.19.0-5-amd64 Done. ...
以上のようにapt-getもうまくいきました。良かった良かった。
< | 2019 | > | ||||
<< | < | 08 | > | >> | ||
日 | 月 | 火 | 水 | 木 | 金 | 土 |
- | - | - | - | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
合計:
本日:
管理者: Katsuhiro Suzuki(katsuhiro( a t )katsuster.net)
This is Simple Diary 1.0
Copyright(C) Katsuhiro Suzuki 2006-2023.
Powered by PHP 8.2.15.
using GD bundled (2.1.0 compatible)(png support.)