YubiKey 06 – OpenPGP Schlüsselpaare erstellen – Master Key und Sub Keys

Die virtuelle Umgebung mit einem aktuellen Ubuntu ist fertig. Die wichtigsten Voraussetzungen sind erfüllt, der am Host angeschlossene YubiKey wird an das Gast-System durchgereicht und dort als Smart Card erkannt.


Schlüssel erstellen

Master Key erstellen
Sub Keys erstellen
Sub Key für Verschlüsselungsnutzbarkeit (Encrypt Capability)
Sub Key für Signaturnutzbarkeit (sign capability)
Sub Key für Authentisierungsnutzbarkeit (authenticate capability)

Achtet darauf, dass euer YubiKey die hier genutzen Funktionalität „Smart Card“ unterstützt!

Schlüssel erstellen

Für unser Vorhaben benötigen wir 4 verschiedene Schlüssel, die einzeln auf unseren YubiKey übertragen werden.

  • Master Key
  • — Sub Key für die Signaturnutzbarkeit – sign capability
  • — Sub Key für doe Verschlüsselungsnutzbarkeit – encrypt capability
  • — Sub Key für die Authentisierungsnutzbarkeit – authenticate capability

Gib mir gerne einen Kaffee ☕ aus!

Wenn dir meine Beiträge gefallen und geholfen haben, dann kannst du mir gerne einen Kaffee ☕ ausgeben.

PayPal Logo


liberapay.com/strobelstefan.org


Kaffee via Bitcoin

bc1qfuz93hw2fhdvfuxf6mlxlk8zdadvnktppkzqzj


Der Master Key ist

    • oberste Schlüssel, der u.a. eure Kontaktdetails enthält, wie Name und E-Mail-Adresse.
    • der die Sub Keys verwaltet
    • der mit einem Passwort geschützt ist und nach dessen Eingabe den Zugriff auf den Master Key selbst und Sub Keys erlaubt. Wir haben also eine hierarchische Ordnung der Keys, ohne einen Master Key lässt sich kein Sub Key anlegen.

Unser Master Key soll nur die Funktionalität „Signaturnutzbarkeit (sign capability)“ erhalten.

Die anderen 3 werden jeweils auf einen Sub Key aufgeteilt.

Mit einem solchen Vorgehen ist man ein wenig flexibler bei der Nutzung. Möchte man z.B. nur die Signaturnutzbarkeit verwenden, reicht der Export des Sub Keys anstatt einen Key mit allen Funktionen auf das Gerät zu übertragen. Des weiteren stellt das ein wenig mehr Sicherheit dar.

Leider kann es bei der Verwendung der deutschen Sprache zu Missverständnissen bei der Anzeige der Schlüsselfunktionen im Terminal kommen.

Im Schlüsselbund werden die Sub Keys angezeigt und in einer eckigen Klammer stehen Buchstaben, die die Funktion des Schlüssels anzeigen.
Die Buchstaben in Klammern können zwischen Deutsch und Englisch unterschiedlich sein. Ich verwende die Englisch für die Erstellung der Schlüssel.

Hier die Gegenüberstellung von Englisch und Deutsch
(S) Toggle the sign capability = Signaturnutzbarkeit
(E) Toggle the encrypt capability = Verschlüsselungsnutzbarkeit
(A) Toggle the authenticate capability = Authentisierungsnutzbarkeit

Die Sprache in Ubuntu lässt sich sehr einfach umstellen, wenn ihr für die Dauer der Schlüsselerstellung auf Englisch wechseln möchtet.

Ubuntu - Sprache umstellen
Ubuntu – Sprache umstellen

Master Key erstellen

Im ersten Schritt wird der Master Key erstellt. Diesem Schlüssel sind standardmäßig alle 3 Schlüsselfunktionen zugeordnet.

Wir möchten aber nur die „Signaturnutzbarkeit (sign capability)“ für den „Master Key“ nutzen. Die anderen Funktionen „lagern“ wir in Sub Key aus.

 

gpg --expert --full-gen-key

 

        • –expert – Expertenmodus wird aktiviert
        • –full-gen-key – Mit dieser Option werden neue Schlüsselpaare erstellt und für jede Option ein Dialog ausgegeben.

 

  gpg (GnuPG) 2.2.20; Copyright (C) 2020 Free Software Foundation, Inc.
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

  Please select what kind of key you want:
     (1) RSA and RSA (default)
     (2) DSA and Elgamal
     (3) DSA (sign only)
     (4) RSA (sign only)
     (7) DSA (set your own capabilities)
     (8) RSA (set your own capabilities)
     (9) ECC and ECC
    (10) ECC (sign only)
    (11) ECC (set your own capabilities)
    (13) Existing key
    (14) Existing key from card
  Your selection? 8

 

In diesem Abschnitt wählen wir die Funktion für den Master Key aus. Wir möchten, dass dieser nur zum „Signieren (= Certify)„“ verwendet werden kann.

Aktuell kann er noch für alle drei Funktionen verwendet werden, durch An- und Abwählen lässt sich das jedoch ändern.

In dem Screenshot wird das dargestellt, wie sich die Funktionen ändern, bis am Ende nur noch „Certify“ übrig bleibt.

YubiKey Funktionen umschalten
YubiKey Funktionen umschalten

 

  Possible actions for a RSA key: Sign Certify Encrypt Authenticate
  Current allowed actions: Sign Certify Encrypt

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

 

Damit ihr für den Master Key zum richtigen Ergebnis kommt, müsst ihr „s, e, q“ auswählen.

 

Possible actions for a RSA key: Sign Certify Encrypt Authenticate
Current allowed actions: Certify

   (S) Toggle the sign capability
   (E) Toggle the encrypt capability
   (A) Toggle the authenticate capability
   (Q) Finished

Your selection? q
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072) 4096
Requested keysize is 4096 bits
Please specify how long the key should be valid.
         0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 5y
Key expires at Do 11 Dez 2025 16:03:37 CET
Is this correct? (y/N) y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) "

Real name: test-benutzer
E-mail address: 
Comment:
You selected this USER-ID:
    "test-benutzer <test-benutzer@testlauf.de>"

    Change (N)ame, (C)omment, (E)-mail or (O)kay/(Q)uit? o
    We need to generate a lot of random bytes. It is a good idea to perform
    some other action (type on the keyboard, move the mouse, utilise the
    disks) during the prime generation; this gives the random number
    generator a better chance to gain enough entropy.
    gpg: key 5C32B7A2290F8AE4 marked as ultimately trusted
    gpg: revocation certificate stored as '/home/dev/.gnupg/openpgp-revocs.d/EE223DBF5644229EFABE52C55C32B7A2290F8AE4.rev'
    public and secret key created and signed.

    pub   rsa4096 2020-12-12 [C] [expires: 2025-12-11]
          EE223DBF5644229EFABE52C55C32B7A2290F8AE4
    uid                      test-benutzer <test-benutzer@testlauf.de>

 

Mit diesen paar Schritten haben wir nun unseren Master Key erstellt.

Im Schlüsselbund können wir den Schlüssel anzeigen lassen. Am Anfang der Zeile steht „pub“ und in der Klammer steht „C„. Das zeigt an, dass es sich auch wirklich um den Master Key handelt.

Sub Keys erstellen

Für die Erstellung der Sub Keys werden weniger Schritte benötigt, da die persönlichen Informationen bereits im Master Key abgespeichert sind, dafür ist der Erstellungsprozess dreimal zu durchlaufen.

Mit dem Befehl kann man zum Master Key mit der ausgewählten ID Sub Keys hinzufügen.
Die ID des Master Keys wird im Schlüsselbund angezeigt.

Zur Erinnerung, wir benötigen 3 Sub Keys mit den Schlüsselfunktionen

        • Sub Key für die Signaturnutzbarkeit = sign capability (S)
        • Sub Key für die Verschlüsselungsnutzbarkeit = encrypt capability (E)
        • Sub Key für die Authentisierungsnutzbarkeit = authenticate capability (A)

 

gpg --expert --edit-key EE223DBF5644229EFABE52C55C32B7A2290F8AE4

gpg (GnuPG) 2.2.20; Copyright (C) 2020 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Secret key is available.

sec  rsa4096/5C32B7A2290F8AE4
     created: 2020-12-12  expires: 2025-12-11  usage: C
     trust: ultimate      validity: ultimate
[ultimate] (1). test-benutzer <test-benutzer@testlauf.de>

gpg> addkey

 

Sub Key für Verschlüsselungsnutzbarkeit (Encrypt Capability)

 

  Please select what kind of key you want:
     (3) DSA (sign only)
     (4) RSA (sign only)
     (5) Elgamal (encrypt only)
     (6) RSA (encrypt only)
     (7) DSA (set your own capabilities)
     (8) RSA (set your own capabilities)
    (10) ECC (sign only)
    (11) ECC (set your own capabilities)
    (12) ECC (encrypt only)
    (13) Existing key
    (14) Existing key from card
  Your selection? 8

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Sign Encrypt

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? s

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Encrypt

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? q
  RSA keys may be between 1024 and 4096 bits long.
  What keysize do you want? (3072) 4096
  Requested keysize is 4096 bits
  Please specify how long the key should be valid.
           0 = key does not expire
          = key expires in n days
        w = key expires in n weeks
        m = key expires in n months
        y = key expires in n years
  Key is valid for? (0) 5y
  Key expires at Do 11 Dez 2025 16:18:43 CET
  Is this correct? (y/N) y
  Really create? (y/N) y
  We need to generate a lot of random bytes. It is a good idea to perform
  some other action (type on the keyboard, move the mouse, utilise the
  disks) during the prime generation; this gives the random number
  generator a better chance to gain enough entropy.

  sec  rsa4096/5C32B7A2290F8AE4
       created: 2020-12-12  expires: 2025-12-11  usage: C
       trust: ultimate      validity: ultimate
  ssb  rsa4096/AC3DF8B5D579D99A
       created: 2020-12-12  expires: 2025-12-11  usage: E
  [ultimate] (1). test-benutzer <test-benutzer@testlauf.de>

  gpg>

 

Der Sub Key wurde automatisch zum Schlüsselbund hinzugefügt.
Mit „ssb“ wird angezeigt, dass es sich um einen Unterschlüssel handelt.
Hinter „usage“ steht das „E“ für „Verschlüsselungsnutzbarkeit (Encrypt Capability)„.

Sub Key für Signaturnutzbarkeit (sign capability)

 

  gpg> addkey
  Please select what kind of key you want:
     (3) DSA (sign only)
     (4) RSA (sign only)
     (5) Elgamal (encrypt only)
     (6) RSA (encrypt only)
     (7) DSA (set your own capabilities)
     (8) RSA (set your own capabilities)
    (10) ECC (sign only)
    (11) ECC (set your own capabilities)
    (12) ECC (encrypt only)
    (13) Existing key
    (14) Existing key from card
  Your selection? 8

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Sign Encrypt

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? e

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Sign

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? q
  RSA keys may be between 1024 and 4096 bits long.
  What keysize do you want? (3072) 4096
  Requested keysize is 4096 bits
  Please specify how long the key should be valid.
           0 = key does not expire
          = key expires in n days
        w = key expires in n weeks
        m = key expires in n months
        y = key expires in n years
  Key is valid for? (0) 5y
  Key expires at Do 11 Dez 2025 16:21:16 CET
  Is this correct? (y/N) y
  Really create? (y/N) y
  We need to generate a lot of random bytes. It is a good idea to perform
  some other action (type on the keyboard, move the mouse, utilise the
  disks) during the prime generation; this gives the random number
  generator a better chance to gain enough entropy.

  sec  rsa4096/5C32B7A2290F8AE4
       created: 2020-12-12  expires: 2025-12-11  usage: C
       trust: ultimate      validity: ultimate
  ssb  rsa4096/AC3DF8B5D579D99A
       created: 2020-12-12  expires: 2025-12-11  usage: E
  ssb  rsa4096/F2F84EBBFEFDC588
       created: 2020-12-12  expires: 2025-12-11  usage: S
  [ultimate] (1). test-benutzer <test-benutzer@testlauf.de>

  gpg>

Der Sub Key wurde automatisch zum Schlüsselbund hinzugefügt.
Mit „ssb“ wird der Unterschlüssel angezeigt.
Hinter „usage“ steht das „S“ für „Signaturnutzbarkeit (sign capability)„.

Sub Key für Authentisierungsnutzbarkeit (authenticate capability)

 

  gpg> addkey
  Please select what kind of key you want:
     (3) DSA (sign only)
     (4) RSA (sign only)
     (5) Elgamal (encrypt only)
     (6) RSA (encrypt only)
     (7) DSA (set your own capabilities)
     (8) RSA (set your own capabilities)
    (10) ECC (sign only)
    (11) ECC (set your own capabilities)
    (12) ECC (encrypt only)
    (13) Existing key
    (14) Existing key from card
  Your selection? 8

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Sign Encrypt

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? a

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Sign Encrypt Authenticate

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? s

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Encrypt Authenticate

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? e

  Possible actions for a RSA key: Sign Encrypt Authenticate
  Current allowed actions: Authenticate

     (S) Toggle the sign capability
     (E) Toggle the encrypt capability
     (A) Toggle the authenticate capability
     (Q) Finished

  Your selection? q
  RSA keys may be between 1024 and 4096 bits long.
  What keysize do you want? (3072) 4096
  Requested keysize is 4096 bits
  Please specify how long the key should be valid.
           0 = key does not expire
          = key expires in n days
        w = key expires in n weeks
        m = key expires in n months
        y = key expires in n years
  Key is valid for? (0) 5y
  Key expires at Do 11 Dez 2025 16:25:33 CET
  Is this correct? (y/N) y
  Really create? (y/N) y
  We need to generate a lot of random bytes. It is a good idea to perform
  some other action (type on the keyboard, move the mouse, utilise the
  disks) during the prime generation; this gives the random number
  generator a better chance to gain enough entropy.

  sec  rsa4096/5C32B7A2290F8AE4
       created: 2020-12-12  expires: 2025-12-11  usage: C
       trust: ultimate      validity: ultimate
  ssb  rsa4096/AC3DF8B5D579D99A
       created: 2020-12-12  expires: 2025-12-11  usage: E
  ssb  rsa4096/F2F84EBBFEFDC588
       created: 2020-12-12  expires: 2025-12-11  usage: S
  ssb  rsa4096/F122ED392968B430
       created: 2020-12-12  expires: 2025-12-11  usage: A
  [ultimate] (1). test-benutzer <test-benutzer@testlauf.de>

  gpg>

 

Der Sub Key wurde automatisch zum Schlüsselbund hinzugefügt.
Mit „ssb“ wird der Unterschlüssel angezeigt.
Hinter „usage“ steht das „A“ für „Authentisierungsnutzbarkeit (authenticate capability)„.


Gib mir gerne einen Kaffee ☕ aus!

Wenn dir meine Beiträge gefallen und geholfen haben, dann kannst du mir gerne einen Kaffee ☕ ausgeben.

PayPal Logo


liberapay.com/strobelstefan.org


Kaffee via Bitcoin

bc1qfuz93hw2fhdvfuxf6mlxlk8zdadvnktppkzqzj


Alle drei Sub Keys sind erstellt und die Bearbeitung kann beendet werden.

  gpg> save

 

Den Schlüsselbund mit allen so eben erstellen Keys könnt ihr euch mit dem Befehl anzeigen lassen.

 

gpg -k
/home/dev/.gnupg/pubring.kbx
----------------------------
pub   rsa4096 2020-12-12 [C] [expires: 2025-12-11]
      EE223DBF5644229EFABE52C55C32B7A2290F8AE4
uid           [ultimate] test-benutzer <test-benutzer@testlauf.de>
sub   rsa4096 2020-12-12 [E] [expires: 2025-12-11]
sub   rsa4096 2020-12-12 [S] [expires: 2025-12-11]
sub   rsa4096 2020-12-12 [A] [expires: 2025-12-11]

 

Möchtet ihr nur die öffentlichen Keys im Schlüsselbund angezeigt bekommen, dann lt. der Befehl so.

gpg -k

oder

gpg --list-keys

 

Die privaten Keys im Schlüsselbund lassen sich mit anzeigen

gpg --list-secret-keys

 

Weiterführende Links
Alle hier verwendeten Befehle können in der offiziellen Dokumentation nachgeschlagen werden.

https://www.gnupg.org/documentation/manuals/gnupg/Option-Index.html nachgeschlagen werden.
https://www.gnupg.org/gph/de/manual/r1023.html

Die Schlüsselpaare sind erstellt, im nächsten Schritt werden Backups und der öffentliche Schlüssel exportiert.
YubiKey 07 – OpenPGP Schlüsselpaare erstellen – Master Key und Sub Keys


Gib mir gerne einen Kaffee ☕ aus!

Wenn dir meine Beiträge gefallen und geholfen haben, dann kannst du mir gerne einen Kaffee ☕ ausgeben.

PayPal Logo


liberapay.com/strobelstefan.org


Kaffee via Bitcoin

bc1qfuz93hw2fhdvfuxf6mlxlk8zdadvnktppkzqzj



Hier geht es zur ➡ YubiKey Themenseite, dort findest du noch mehr Beiträge rund um den YubiKey.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert