LOGBOOK

HELP

Quiz Entry - updated: 2026.11.30

Grafana is installed from Grafana Labs' own apt repository. Why is a GPG key downloaded first, and what does signed-by= in the repository line do?

The key lets apt check that the repository's package lists, and through them the packages, really come from Grafana Labs and were not tampered with. signed-by= limits that key's trust to this one repository.

Chain of trust in apt: the grafana.key named by signed-by verifies the signed Release file, which lists the hash of the Packages index, which lists the hash of grafana.deb; the key is not trusted for Debian's own repositories

* One signature at the top, hashes all the way down, and the key counts for this repository only. *

sudo wget -q -O /usr/share/keyrings/grafana.key https://packages.grafana.com/gpg.key
echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://packages.grafana.com/oss/deb stable main" \
  | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt update && sudo apt install -y grafana

How the check works: the repository publishes a Release file signed with Grafana Labs' private key. It lists the hashes of the package indexes, and the indexes list the hash of every .deb. apt verifies the signature with the public key, then each hash down the chain, so a mirror or attacker who swaps a package breaks the chain and the install is refused.

Why signed-by=: the older apt-key add put a key into the global keyring, where it was trusted for every repository, so a third-party key could also vouch for packages pretending to come from Debian. Pointing one repository at one key file is least privilege for package sources.

After the install, the package has created the grafana-server service but not enabled it: sudo systemctl daemon-reload, sudo systemctl enable --now grafana-server, and systemctl status grafana-server shows whether it runs. The web interface then listens on port 3000. (Grafana Labs now also publish the same repository as https://apt.grafana.com, with the key stored under /etc/apt/keyrings/; the mechanism is identical.)

Go deeper:

From Quiz: ITIA / Monitoring Lab: Prometheus and Grafana | Updated: Nov 30, 2026