zh-CN:Pacman-key A tool used to help set-up and manage package signing security in Arch Linux.
- 1 Introduction
- 2 Setup
- 3 Managing the keyring
- 4 Troubleshooting
- 5 Further Reading
Pacman uses GnuPGP keys in a web of trust model to determine if packages are authentic. There are currently five Master Signing Keys. At least three of these Master Signing Keys are used to sign each of the Developer's and Trusted User's own keys which then in turn are used to sign their packages. The user also has a unique PGP key which is generated when you set up pacman-key. So the web of trust links the user's key to the five Master Keys.
Examples of webs of trust:
- Custom packages: You made the package yourself and signed it with your own key.
- Unofficial packages: A developer made the package and signed it. You used your key to sign that developer's key.
- Official packages: A developer made the package and signed it. The developer's key was signed by the Arch Linux master keys. You used your key to sign the master keys, and you trust them to vouch for developers.
SigLevel option in
/etc/pacman.conf determines how much trust is required to install a package. For a detailed explanation of SigLevel see the pacman.conf man page and the comments in the file itself. Signature checking may be set globally or per repository. If SigLevel is set globally in the [options] section to require all packages to be signed, then packages you build will also need to be signed using
Requiredis set then
DatabaseOptionalshould also be set, eg:
SigLevel = Required DatabaseOptional TrustedOnlyThis way pacman will only install packages that are signed by keys that you trust.
SigLevel = PackageRequiredis going to be standard for verifying official packages:
[core] SigLevel = PackageRequired Include = /etc/pacman.d/mirrorlist
TrustAlloption exists for debugging purposes and makes it very easy to trust keys that have not been verified. You should use
TrustedOnlyfor all official repositories.
Initializing the keyring
To set up the pacman keyring use:
# pacman-key --init
For this initialization entropy is required. Moving your mouse around, pressing random characters at the keyboard or running some disk-based activity (for example in another console running
ls -R /) should generate entropy. The initialization can take a few minutes, but may take much longer if you do not already have sufficient entropy and do not create any.
This will set up a new keyring in
/etc/pacman.d/gnupg and generate a unique master key for your system.
For pacman to start checking package signatures you have to import the developers keys to your keyring. The next section explains how to do so.
pacman-key --initover ssh, install the package on the target machine. Connect via ssh and do the following:
# rc.d start haveged # pacman-key --init
After pacman-key successfully ran simply stop haveged and remove the package.
# rc.d stop haveged # pacman -Rs haveged
Managing the keyring
Verifying the five Master keys
The initial setup of keys is achieved using:
# pacman-key --populate archlinux.
Take time to verify the Master Signing Keys when prompted as these are used to co-sign (and therefore trust) all other packager's keys.
PGP keys are too large (2048 bits or more) for humans to work with, so they are usually hashed to create a 40-hex-digit fingerprint which can be used to check by hand that two keys are the same. The last eight digits of the fingerprint serve as a name for the key known as the 'key ID'.
Adding Developer keys
The official developer and TU keys are signed by the master keys, so you do not need to use pacman-key to sign them yourself. Whenever pacman encounters a key it does not recognize, it will promt to download it from a
keyserver configured in
/etc/pacman.d/gnupg/gpg.conf (or by using the
--keyserver option on the command line). Wikipedia maintains a list of keyservers.
Once you have downloaded a developer key, you will not have to download it again, and it can be used to verify any other packages signed by that developer.
# pacman-key --refresh-keysWhile doing
--refresh-keys, your local key will also be looked up on the remote keyserver, and you will receive a message about it being not found. This is nothing to be concerned about.
Adding Unofficial keys
First, get the ID from the owner of the key. Run:
# pacman-key -r <keyid>
to download it from a keyserver. Be sure to verify the fingerprint, as you would with a master key, or any other key which you are going to sign. After verifying the fingerprint, you need to locally sign this key:
# pacman-key --lsign-key <keyid>
You now trust this key to sign packages.
If pacman-key is not enough, you can manage pacman's keyring by gpg like this:
# gpg --homedir /etc/pacman.d/gnupg $OPTIONS
# env GNUPGHOME=/etc/pacman.d/gnupg gpg $OPTIONS
Cannot import keys
Some ISPs block the port used to import PGP keys. One solution is to use the MIT keyserver, which provides an alternate port. To do this, edit
/etc/pacman.d/gnupg/gpg.conf and change the keyserver line to:
If you happen to forget to run
pacman-key --populate archlinux you might get some errors while importing keys.
Disabling signature checking
If you are not concerned about package signing, you can disable PGP signature checking completely. Edit
/etc/pacman.conf and uncomment the following line under [options]:
SigLevel = Never
You need to comment out any repository-specific SigLevel settings too because they override the global settings. This will result in no signature checking, which was the behavior before pacman 4. If you decide to do this, you do not need to set up a keyring with pacman-key. You can change this option later if you decide to enable package verification.
Resetting all the keys
If you want to remove or reset all the keys installed in your system, you can remove
/etc/pacman.d/gnupg folder as root and rerun
pacman-key --init and following that add the keys as preferred.