How to transfer the apt keyring to another computer

I'm currently moving my installation of Ubuntu from one laptop to another. Both laptops run Ubuntu 14.04. I moved my /etc/apt/sources.list, the contents of my home directory, and installed all packages from the old laptop on the new one. Now I want to transfer the apt keyring, because I think it will be easier than tracking down all the keys and installing them manually. What's the best way to do that?


Solution 1:

The apt-key command can export all trusted keys:

apt-key exportall > trusted-keys

Copy the trusted-keys file to the other system and import them:

sudo apt-key add trusted-keys

Exporting via apt-key doesn't need root privilege, but importing does.