APT/Fehlerbehebung: Unterschied zwischen den Versionen

Aus Foxwiki
Zeile 81: Zeile 81:
  2 packages can be upgraded. Run 'apt list --upgradable' to see them.
  2 packages can be upgraded. Run 'apt list --upgradable' to see them.
== exec of /tmp/... failed: Permission denied ==
== exec of /tmp/... failed: Permission denied ==
=== Ursache ===
=== Ursache ===
/tmp/ wurde mit der Option ''noexec'' gemountet
/tmp/ wurde mit der Option ''noexec'' gemountet



Version vom 24. November 2022, 23:25 Uhr

Schlüssel ist im veralteten Schlüsselbund trusted.gpg gespeichert

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).

Diese Fehlermeldung erscheint seit Debian 11, wenn man versucht, einen neuen GPG-Schlüssel hinzuzufügen.

Bislang wurde für Drittanbieter-Paketquellen von APT-Paketen der öffentliche Schlüssel heruntergeladen und an apt-key add übergeben:

$ wget -q -O - https://download.bell-sw.com/pki/GPG-KEY-bellsoft | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

Hintergrund

Per APT verteilte Softwarepakete werden signiert.

  • Damit soll sichergestellt werden, dass ihr wirklich die originalen Pakete von der jeweiligen Organisation wie Debian erhaltet.
  • Wie das im Detail funktioniert, hängt mit asymmetrischer Verschlüsselung und der Funktionsweise von PGP zusammen.
    • Das würde hier den Rahmen sprengen.
    • Wir belassen es daher an der Stelle dabei, dass sich mit der Signatur die Integrität der Pakete sicherstellen lässt – was grundsätzlich eine sinnvolle Sache ist und die Sicherheit erhöht.

Mit apt-key add wird der öffentlichen Schlüssel des Repositorys gespeichert und ihm vertraut

  • Ansonsten hätte das System kein Vertrauensverhältnis – die Installation von Paketen aus nicht vertrauenswürdigen Quellen würde abgewiesen
  • Kann man selbst testen, indem man eine Drittanbieter-Paketquelle hinzufügt, ohne vorher deren öffentlichen Schlüssel zu importieren

apt-key ist veraltet

  • Fügt ihr einen neuen Schlüssel mit apt-key hinzu, wird dieser in einen Ordner von vertrauenswürdigen Schlüsseln (konkret /etc/apt/trusted.gpg.d) abgelegt.
  • Wenn man ein Paket installiert, prüft apt, ob es von irgendjemandem signiert wurde, dessen Schlüsseln wir vertrauen.
  • Es wird nicht vorher abgefragt, ob der Schlüssel zu der Paketquelle passt.

Das ist zwar immer noch sicherer als gar keine Signaturen zu verwenden, aber es schwächt die Sicherheit.

  • Besser wäre es, wenn ein Schlüssel nur für das dazugehörige Repository akzeptiert wird.
  • Also eine 1:1 Beziehung, statt eines generellen, bedingungslosen Vertrauensverhältnisses.
  • Aus diesem Grunde wurde apt-key als veraltet markiert, damit man auf dieses neue Verfahren wechselt.

Seit Debian 11 bzw. Ubuntu 22.04 ist 'apt-key nur als veraltet markiert und daher weiterhin verfügbar.

  • Allerdings ist das die letzte Hauptversion!
  • Mit der nächsten Version von Debian bzw. Ubuntu wird es aller Voraussicht nach entfernt.
  • Ich werde es daher in den Beiträgen nicht mehr einsetzen und ihr solltet es möglichst auch nicht mehr tun.

Schlüssel hinzufügen

Zunächst braucht es einen Ordner: /etc/apt/trusted.gpg.d sollte nicht verwendet werden, sondern ein eigener Ordner.

  • Dieser ist frei Wählbar, ein sinnvoller Pfad könnte z.B. /usr/local/share/keyrings sein.
sudo mkdir /usr/local/share/keyrings

Als Nächstes brauchen wir den öffentlichen PGP-Schlüssel.

  • Der wird wie zuvor heruntergeladen, aber in eine Datei.
  • Es macht an der Stelle Sinn, gleich mit file zu prüfen, ob es wirklich ein PGP-Key ist.
  • Nicht von old verwirren lassen, „PGP public key block Public-Key (old)“ ist in Ordnung.
$ wget -q -O key.gpg https://download.bell-sw.com/pki/GPG-KEY-bellsoft
$ file key.gpg
key.gpg: PGP public key block Public-Key (old)

Nun müssen wir uns einen Schlüsselring erstellen, den wir APT übergeben können:

$ gpg --no-default-keyring --keyring ./tmp.gpg --import key.gpg
gpg: key 32E9750179FCEA62: public key "BellSoft LLC <info@bell-sw.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1

$ gpg --no-default-keyring --keyring ./tmp.gpg --export --output bell-sw.gpg

$ rm tmp.gpg key.gpg

Fertig ist bell-sw.gpg, der hier auch gleich einen sprechenden Namen zur Zuordnung erhalten hat.

  • Diesen verschieben wir nun in das zuvor erstellte Verzeichnis:
sudo mv bell-sw.gpg /usr/local/share/keyrings

Auf den verweist du nun im Eintrag deiner deb-Paketquelle.

  • Es empfiehlt sich, eine Liste pro Repository/Hersteller in /etc/apt/sources.list.d anzulegen, die auf .list endet.
  • In meinem Beispiel lege ich also /etc/apt/sources.list.d/bell-sw.list an.
  • Im normalen Paketquellen-Eintrag fügt man zwischen deb und der URL folgendes ein:
[signed-by=/usr/local/share/keyrings/bell-sw.gpg]

Beispiel:

deb [arch=amd64 signed-by=/usr/local/share/keyrings/bell-sw.gpg] https://apt.bell-sw.com/ stable main

Dies ist natürlich entsprechend der Architektur, Paketquellen-URL und ggf. des von dir gewählten Pfades anzupassen.

Nun kannst du die Paketquellen ganz normal via sudo apt update aktualisieren, damit sich apt den Paketindex aus dem neu hinzugefügten Repository laden kann.

  • Hier sollte euer Repository (im Beispiel apt.bell-sw.com) gelistet sein und keine Fehlermeldung erscheinen.
$ sudo apt update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:4 http://deb.debian.org/debian bullseye-updates InRelease
Get:5 https://apt.bell-sw.com stable InRelease [4,166 B]
Get:6 https://apt.bell-sw.com stable/main arm64 Packages [18.2 kB]
Fetched 22.4 kB in 2s (12.6 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.

exec of /tmp/... failed: Permission denied

Ursache

/tmp/ wurde mit der Option noexec gemountet

Temporäre Lösung

Remount the temp location (/tmp) with "exec" permission.

mount -o remount,exec /tmp

Dauerhafte Lösung

Apt kann den Remount vor und nach jedem Aufruf übernehmen.

  • Dazu folgende Zeilen ergänzen in /etc/apt/apt.conf:
DPkg::Pre-Invoke {"mount -o remount,exec /tmp";};
DPkg::Post-Invoke {"mount -o remount /tmp";};

Alternativ kann das Verzeichnis geändert werden, das nicht mit noexec gemeountet ist:

APT::ExtractTemplates::TempDir "/var/tmp";

sub-process /usr/bin/dpkg returned an error code (1)

The error message “Sub-process /usr/bin/dpkg returned an error code (1)” indicates a problem with the package installer.

  • This can happen after a failed software installation, or if the installer becomes corrupted.

The key phrase in this error is /usr/bin/dpkg.

  • This refers to the dpkg package installer for Linux.
  • A package installer is an application that tracks software, updates, and dependencies.
  • If it is damaged, any new software installation will cause this error message.

We cover several possible solutions, from easily solved and straightforward solutions to more complex processes.

  • This guide will help you resolve the dpkg returned an error code 1 on an Ubuntu operating system.

Options to Fix

Reconfigure dpkg Database

If your package database has become corrupted, reconfiguring it can repair it.

sudo dpkg ––configure –a

This command reconfigures packages that have been unpacked but not necessarily installed.

  • An interruption at the wrong time can cause this database to become corrupt.
  • This is especially helpful if you were running installation and the process was interrupted.

Force-Install the Software

If Method 1 does not work, you can attempt to fix the dependencies in the package installer.

sudo apt-get install –f

The –f option means fix-broken.

  • It repairs any broken dependencies in your package manager.
  • Broken dependencies occur when a download is interrupted, or there is a problem with the cached download.

Note: Dependencies are other software packages that are required by the software you are installing.

  • A package manager helps keep track of dependencies for you.

Remove Bad Software Package

If you know which software caused the errors on your system, you can remove it.

Enter the command and package_name with the name of the software that is causing the problem:

sudo apt-get remove ––purge package_name

The ––purge option directs the system to remove config files in addition to uninstalling.

  • This helps get rid of all traces of the offending software.

Clean Out Unused Software Packages

If an old, outdated, or unused package is causing the problem, you can solve the problem by removing unused software packages.

sudo apt autoremove

Note: Avoid the next 2 options unless all other methods have failed.

Remove Post Files

If you know the name of the package that is causing problems, you can delete the files manually.

  • The installation files are usually located in the /var/lib/dpkg/info file.

Type in the following command and replace package_name with the name of the broken software.:

sudo ls –l /var/lib/dpkg/info | grep –i package_name

This will generate a list of all references to the software you installed.You can then remove them by entering:

sudo mv /var/lib/dpkg/info/package_name.* /tmp

This command moves the files to the /tmp directory, where they cannot affect your package manager.

Next, update the package manager:

sudo apt-get update

After which you can re-install the broken software again.

Overwrite Package File

If you know the name of the package that is causing a problem, you can force an overwrite.

Use the following command and replace full_name_of_package with the actual package name:

sudo dpkg –i ––force–overwrite /var/cache/apt/archives/full_name_of_package

Note: If you do not know the actual name of the package, you can search for it with the following command:

ls /var/cache/apt/archies/*package_name*

Replace package_name with the name of your software.

  • This should return any instances of that package name.
  • Note the exact filename, and type it into the previous command.

Quelle

  1. https://phoenixnap.com/kb/fix-sub-process-usr-bin-dpkg-returned-error-code-1

dependencies error libc

Lösung

dpkg --configure -a
apt-get install ibritish iamerican ienglish-common ispell locales libc6=2.28-10 libc-bin=2.28-10
apt clean
apt autoclean
apt update
apt upgrade
systemctl restart sshd.service