-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapt_key.sh
54 lines (48 loc) · 1.79 KB
/
apt_key.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# vim:set syntax=sh:
# kate: syntax bash;
# SPDX-License-Identifier: CC-BY-SA-4.0
# Copyright 2021 Jakob Meng, <[email protected]>
exit # do not run any commands when file is executed
#
# APT key management
#
####################
# show/list installed apt keys
#
# the short key id is no longer shown when you use the list command, but it is actually the last 8 characters of the long hex
# Ref.: https://askubuntu.com/a/846877/836620
apt-key list
####################
# Receive and import gpg keys for apt repositories
#
# References:
# man apt-key fingerprint
# TODO: Incorporate https://blog.jak-linux.org/2021/06/20/migrating-away-apt-key/
# On Debian 10 (Buster)
#
# NOTE:
# "
# apt-key supports only the binary OpenPGP format (also known as "GPG key public ring") in
# files with the "gpg" extension, not the keybox database format introduced in newer gpg(1)
# versions as default for keyring files. Binary keyring files intended to be used with any
# apt version should therefore always be created with gpg --export.
#
# Alternatively, if all systems which should be using the created keyring have at least apt
# version >= 1.4 installed, you can use the ASCII armored format with the "asc" extension
# instead which can be created with gpg --armor --export.
# "
# Ref.: man apt-key fingerprint
wget 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0893DC134548A28D' -O the-asc-file.asc
vi the-asc-file.asc # remove html
gpg --dearmor < the-asc-file.asc > the-gpg-file.gpg
cp -raiv the-gpg-file.gpg /etc/apt/trusted.gpg.d/
apt-get update
# On Debian 8 (Jessie) or older
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys A70DAF536070D3A1
gpg --export A70DAF536070D3A1 | apt-key add -
apt-get update
# or
wget http://pfad/zum/key.gpg -O- | apt-key add -
apt-get update
####################