debian – 夏清然的日志 https://www.qingran.net Xia Qingran Geek Blog Sun, 07 Aug 2016 09:50:33 +0000 en-US hourly 1 https://wordpress.org/?v=4.6.1 112893047 建立Debian APT mirror https://www.qingran.net/2010/06/%e5%bb%ba%e7%ab%8bdebian-apt-mirror/ https://www.qingran.net/2010/06/%e5%bb%ba%e7%ab%8bdebian-apt-mirror/#comments Wed, 30 Jun 2010 08:48:37 +0000 https://www.qingran.net/?p=444 最近在公司内网给开发组内的兄弟建Xen虚拟机,guest装的都是debian lenny,所以就在内网做了一个apt mirror,笔记如下。

0,安装apt-mirror

apt-get install apt-mirror

1,修改/etc/apt/mirror.list为以下内容

# 同时发起的wget数,根据自己网络调整
set nthreads 20

set _tilde 0

deb http://mirrors.163.com/debian stable contrib main non-free

deb-src http://mirrors.163.com/debian stable contrib main non-free

clean http://ftp.us.debian.org/debian

2, 下载源,这个进行了1整夜。

apt-mirror

3,修改web server配置,指向下载的目录 ,以nginx的配置为例:

location ^~ /debian {

root /var/spool/apt-mirror/mirror/mirrors.163.com/;

autoindex on;

}

然后重启nginx

4,修改使用此mirror的debian /etc/apt/sources.llist 文件

deb http://mirrors.163.com/debian stable contrib main non-free

deb-src  http://mirrors.163.com/debian stable contrib main non-free

5,同步apt

apt-get update

开始使用吧。

]]>
https://www.qingran.net/2010/06/%e5%bb%ba%e7%ab%8bdebian-apt-mirror/feed/ 2 444
Debian Secure APT简介 https://www.qingran.net/2009/11/debian-secure-apt%e7%ae%80%e4%bb%8b/ https://www.qingran.net/2009/11/debian-secure-apt%e7%ae%80%e4%bb%8b/#comments Mon, 02 Nov 2009 10:46:44 +0000 https://www.qingran.net/?p=468 简单说一下Debian APT体系中为了保证deb包的完整性和可信,建立的一套secure apt体系。

这次升级ubuntu 9.10系统后直接把/etc/apt/sources.list里面google、opera和skype的源的地址直接拷贝了过来,结果apt-get update的时候总是报gpg签名的错误:

“W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used.GPG error: http://dl.google.com stable Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY A040830F7FAC5991“

详细查探了一下原因,原来是因为debian 的 secure apt体系的约束。

secure apt也叫apt-secure是从apt 0.6版本开始引入,时间是在2003年。secure apt的作用是使用数字签名和加密对所有下载包的进行验证。

数字签名目前同时使用了md5、sha-1、sha256等三种签名方式。
首先在每个源、每种架构(i386、amd64)目录都存在了一个Packages.bz2内保存了所有包的checksum文件
例如:

wget http://archive.ubuntu.com/ubuntu/dists/lucid-security/multiverse/binary-i386/Packages.bz2
bzless Packages.bz2

可以看到如下内容:

Filename: pool/multiverse/f/flashplugin-nonfree/flashplugin-installer_10.1.53.64ubuntu0.10.04.1_i386.deb
Size: 19748
MD5sum: 9f0e2dcbdcbfe5df425334aabcd19b68
SHA1: 59dbb008eeba133a994e6a440042f49ed4876175
SHA256: 60d0ded6de08418ee99aa5d667bed9f1e4d2f76334e188b21386abdb343821f3

同时为了保证Packages.bz2的完整性呢, 又通过在的Release文件内加入对Package.bz2文件的签名来保证:
可以打开http://archive.ubuntu.com/ubuntu/dists/lucid-security/Release文件查看。

那么,Release文件的完整性如何来保证?此时为Release引入了GPG签名,可见http://archive.ubuntu.com/ubuntu/dists/lucid-security
/Release.gpg

当执行

apt-get update

apt系统先取到Release.gpg,此文件是一个GPG的签名结果,apt使用存储在/etc/apt/trusted.gpg内的GPG key对同位置下的Release文件进行签名,并把签名结果和Release.gpg进行比较,如果相同就通过,否则就会报最开始的“NO_PUBKEY”错误。

验证apt key的匹配可以通过以下步骤进行验证:

cd /var/lib/apt/lists
gpgv --keyring /etc/apt/trusted.gpg archive.ubuntu.com_ubuntu_dists_lucid-updates_Release.gpg\ archive.ubuntu.com_ubuntu_dists_lucid-updates_Release

同时列出当前的apt key(通过读取/etc/apt/trusted.gpg文件):

apt-key list

添加一个key

gpg --keyserver subkeys.pgp.net --recv-keys
gpg -a --export  | sudo apt-key add -

同时查看一个软件包的HASH签名:

apt-cache show  | egrep '(^MD5|^SHA1|^SHA256)'

参考资料
http://wiki.debian.org/SecureApt

]]>
https://www.qingran.net/2009/11/debian-secure-apt%e7%ae%80%e4%bb%8b/feed/ 1 468