Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
nitrokey:arch:3a [16.12.2024 19:28. ] – [Nitrokey Start und Secure Shell] djangonitrokey:arch:3a [16.12.2024 20:52. ] (aktuell) django
Zeile 230: Zeile 230:
 Authentication key: [none] Authentication key: [none]
 General key info..: [none]</code> General key info..: [none]</code>
 +
 +==== nitropy ====
 +FIXME 
 +
 +
 +
 +
 +   # pacman -S python-pynitrokey
 +
 +
 +   # nitropy --help
 +<code>Usage: nitropy [OPTIONS] COMMAND [ARGS]...
 +
 +Options:
 +  -h, --help  Show this message and exit.
 +
 +Commands:
 +  fido2    Interact with Nitrokey FIDO2 devices, see subcommands.
 +  list     List Nitrokey devices (in firmware or bootloader mode)
 +  nethsm   Interact with NetHSM devices, see subcommands.
 +  nk3      Interact with Nitrokey 3 devices, see subcommands.
 +  nkpk     Interact with Nitrokey Passkey devices, see subcommands.
 +  pro      Interact with Nitrokey Pro devices, see subcommands.
 +  start    Interact with Nitrokey Start devices, see subcommands.
 +  storage  Interact with Nitrokey Storage devices, see subcommands.
 +  version  Version of pynitrokey library and tool.</code>
 +
 +   # nitropy nk3 test
 +<code>Command line tool to interact with Nitrokey devices 0.6.0
 +THIS COMMAND SHOULD NOT BE RUN AS ROOT!
 +
 +Please install udev rules and run `nitropy` as regular user (without sudo).
 +We suggest using: https://raw.githubusercontent.com/Nitrokey/libnitrokey/master/data/41-nitrokey.rules
 +For more information, see: https://docs.nitrokey.com/software/nitropy/linux/udev.html
 +
 +Set ALLOW_ROOT=1 environment variable to disable this warning.
 +
 +Found 1 NK3 device(s):
 +- Nitrokey 3 at /dev/hidraw0
 +
 +Running tests for Nitrokey 3 at /dev/hidraw0
 +
 +[1/5] uuid      UUID query              SUCCESS  6447F2534D3A582D0000000000000000
 +[2/5] version  Firmware version query  SUCCESS  v1.7.2
 +[3/5] status    Device status            SUCCESS  Status(init_status=<InitStatus: 0>, ifs_blocks=241, efs_blocks=471, variant=<Variant.NRF52: 2>)
 +Running SE050 test: |                                                                                                                                                                                 
 +[4/5] se050    SE050                    SUCCESS  SE050 firmware version: 3.1.1 - 1.11, (persistent: (30140,), transient_deselect: (271,), transient_reset: (256,))
 +Please press the touch button on the device ...
 +Please press the touch button on the device ...
 +[5/5] fido2    FIDO2                    SUCCESS 
 +
 +5 tests, 5 successful, 0 skipped, 0 failed
 +
 +Summary: 1 device(s) tested, 1 successful, 0 failed</code>
 +
 +Das Protokoll im Verzeichnis **''/tmp''** von **''nitropy''** zeigt im Zweifelsfall weitere Informationen die bei der weiteren Betrachtung oder Fehlereingrenzung wertvolle Informationen liefern kann.
 +
 +   # ls -al /tmp/nitropy.log.gkod8a3k 
 +<code>-rw-r--r-- 1 root root 5795 Dec 16 21:16 /tmp/nitropy.log.gkod8a3k</code>
 +
 +   # cat /tmp/nitropy.log.gkod8a3k
 +<code>368        INFO pynitrokey.cli Timestamp: 2024-12-16 21:16:27.120247
 +368        INFO pynitrokey.cli OS: uname_result(system='Linux', node='pml010074', release='6.6.65-1-lts', version='#1 SMP PREEMPT_DYNAMIC Wed, 11 Dec 2024 15:35:54 +0000', machine='x86_64')
 +368        INFO pynitrokey.cli Python version: 3.12.7
 +369        INFO pynitrokey.cli Cli arguments: ['nk3', 'test']
 +372        INFO pynitrokey.cli pynitrokey version: 0.6.0
 +373        INFO pynitrokey.cli cryptography version: 43.0.3
 +374        INFO pynitrokey.cli ecdsa version: 0.19.0
 +374        INFO pynitrokey.cli fido2 version: 1.1.3
 +375        INFO pynitrokey.cli pyusb version: 1.2.1
 +376        INFO pynitrokey.cli.trussed.test platform: Linux-6.6.65-1-lts-x86_64-with-glibc2.40
 +376        INFO pynitrokey.cli.trussed.test uname: uname_result(system='Linux', node='pml010074', release='6.6.65-1-lts', version='#1 SMP PREEMPT_DYNAMIC Wed, 11 Dec 2024 15:35:54 +0000', machine='x86_64')
 +512       DEBUG       root print: Found 1 NK3 device(s):
 +512       DEBUG       root print: - Nitrokey 3 at /dev/hidraw0
 +512       DEBUG       root print: Running tests for Nitrokey 3 at /dev/hidraw0
 +520       DEBUG       root print: [1/5] uuid      UUID query              SUCCESS  6447F2534D3A582D0000000000000000
 +528       DEBUG       root print: [2/5] version  Firmware version query  SUCCESS  v1.7.2
 +536        INFO pynitrokey.cli.trussed.tests Device status: Status(init_status=<InitStatus: 0>, ifs_blocks=241, efs_blocks=471, variant=<Variant.NRF52: 2>)
 +536       DEBUG       root print: [3/5] status    Device status            SUCCESS  Status(init_status=<InitStatus: 0>, ifs_blocks=241, efs_blocks=471, variant=<Variant.NRF52: 2>)
 +669       DEBUG       root print: [4/5] se050    SE050                    SUCCESS  SE050 firmware version: 3.1.1 - 1.11, (persistent: (30140,), transient_deselect: (271,), transient_reset: (256,))
 +1782      DEBUG fido2.server Fido2Server initialized for RP: PublicKeyCredentialRpEntity(name='Example RP', id='example.com')
 +1782      DEBUG fido2.server Starting new registration, existing credentials: 
 +1786      DEBUG       root print: Please press the touch button on the device ...
 +1796      DEBUG fido2.client Register a new credential for RP ID: example.com
 +1838      DEBUG fido2.ctap2.base Calling CTAP2 make_credential
 +1996      DEBUG  fido2.hid Got keepalive status: 01
 +2248      DEBUG  fido2.hid Got keepalive status: 01
 +2496      DEBUG  fido2.hid Got keepalive status: 01
 +2748      DEBUG  fido2.hid Got keepalive status: 01
 +2996      DEBUG  fido2.hid Got keepalive status: 01
 +3248      DEBUG  fido2.hid Got keepalive status: 01
 +3496      DEBUG  fido2.hid Got keepalive status: 01
 +3744      DEBUG  fido2.hid Got keepalive status: 01
 +3996      DEBUG  fido2.hid Got keepalive status: 01
 +4244      DEBUG  fido2.hid Got keepalive status: 02
 +4496      DEBUG  fido2.hid Got keepalive status: 01
 +4744      DEBUG  fido2.hid Got keepalive status: 01
 +4996      DEBUG  fido2.hid Got keepalive status: 01
 +5244      DEBUG  fido2.hid Got keepalive status: 01
 +5492      DEBUG  fido2.hid Got keepalive status: 01
 +5744      DEBUG  fido2.hid Got keepalive status: 01
 +5992      DEBUG  fido2.hid Got keepalive status: 01
 +6244      DEBUG  fido2.hid Got keepalive status: 01
 +6492      DEBUG  fido2.hid Got keepalive status: 01
 +6740      DEBUG  fido2.hid Got keepalive status: 01
 +6992      DEBUG  fido2.hid Got keepalive status: 01
 +7240      DEBUG  fido2.hid Got keepalive status: 01
 +7492      DEBUG  fido2.hid Got keepalive status: 01
 +7740      DEBUG  fido2.hid Got keepalive status: 01
 +7992      DEBUG  fido2.hid Got keepalive status: 01
 +8256      DEBUG  fido2.hid Got keepalive status: 01
 +8512      DEBUG  fido2.hid Got keepalive status: 01
 +8796      DEBUG  fido2.hid Got keepalive status: 01
 +9056      DEBUG  fido2.hid Got keepalive status: 01
 +9199      DEBUG fido2.server Verifying attestation of type packed
 +9200       INFO fido2.server New credential registered: a3005878bd496f7f5e7c10b12264abdc7274b8a2a8a1724eab6a6b2cf29737921dfb1c4793c1b3645547b7287ca5cd6087b3cd0c06e03c9115de4aeba206f2cfc14da879c4cf8c2045165008c9b3aa4591cee5b2cb825ee6c86f4ebe2f6bc8c4769902a550d389e11b235485931334234f15bf64de04d075aa27d394014c680a5adb95a30d02ed6d9e7f02505d85c63ba65a973e074ce94856cbb2a0
 +9201      DEBUG fido2.server Starting new authentication, for credentials: a3005878bd496f7f5e7c10b12264abdc7274b8a2a8a1724eab6a6b2cf29737921dfb1c4793c1b3645547b7287ca5cd6087b3cd0c06e03c9115de4aeba206f2cfc14da879c4cf8c2045165008c9b3aa4591cee5b2cb825ee6c86f4ebe2f6bc8c4769902a550d389e11b235485931334234f15bf64de04d075aa27d394014c680a5adb95a30d02ed6d9e7f02505d85c63ba65a973e074ce94856cbb2a0
 +9202      DEBUG       root print: Please press the touch button on the device ...
 +9206      DEBUG fido2.client Assert a credential for RP ID: example.com
 +9237      DEBUG fido2.ctap2.base Calling CTAP2 get_assertion
 +9304      DEBUG  fido2.hid Got keepalive status: 02
 +9552      DEBUG  fido2.hid Got keepalive status: 01
 +9804      DEBUG  fido2.hid Got keepalive status: 01
 +10052     DEBUG  fido2.hid Got keepalive status: 01
 +10328     DEBUG  fido2.hid Got keepalive status: 01
 +10588     DEBUG  fido2.hid Got keepalive status: 01
 +10755      INFO fido2.server Credential authenticated: a3005878bd496f7f5e7c10b12264abdc7274b8a2a8a1724eab6a6b2cf29737921dfb1c4793c1b3645547b7287ca5cd6087b3cd0c06e03c9115de4aeba206f2cfc14da879c4cf8c2045165008c9b3aa4591cee5b2cb825ee6c86f4ebe2f6bc8c4769902a550d389e11b235485931334234f15bf64de04d075aa27d394014c680a5adb95a30d02ed6d9e7f02505d85c63ba65a973e074ce94856cbb2a0
 +10755     DEBUG       root print: [5/5] fido2    FIDO2                    SUCCESS
 +10756     DEBUG       root print: 5 tests, 5 successful, 0 skipped, 0 failed
 +10756     DEBUG       root print: Summary: 1 device(s) tested, 1 successful, 0 failed</code>
 +
 +==== webauthn.io ====
 +
 +Was ist WebAuthn?
 +
 +Willkommen auf webauthn.io! Diese Website wurde von Duo Labs entwickelt, um WebAuthn und Passkeys zu testen. WebAuthn wird von allen gängigen Browsern, einschließlich Chrome, Safari und Firefox, sowie von allen modernen Betriebssystemen, einschließlich Android, iOS, macOS und Windows, unterstützt.
 +
 +Eine Einführung in WebAuthn und seine Funktionen finden Sie unter webauthn.guide. Wenn Sie Ihre Website um WebAuthn-Unterstützung erweitern möchten, sind Sie bei passkeys.dev richtig. Der Code für diese Demo ist auf GitHub verfügbar.
 +
 +https://webauthn.guide/
 +
 +https://webauthn.io/
 +
 +
  
 ===== Anwendungsfälle - Software ===== ===== Anwendungsfälle - Software =====
Zeile 1407: Zeile 1551:
 Nun stecken wir unseren Nitrokey Start an den USB-Port und fragen den Kartenstatus ab. Nun stecken wir unseren Nitrokey Start an den USB-Port und fragen den Kartenstatus ab.
    $ gpg2 --card-status    $ gpg2 --card-status
-<code>Reader ...........: 20A0:4211:FSIJ-1.2.19-43243711:0 +<code>Reader ...........: 20A0:42B2:X:0 
-Application ID ...: D276000124010200FFFE432437110000+Application ID ...: D276000124010304000F6447F2530000
 Application type .: OpenPGP Application type .: OpenPGP
-Version ..........: 2.0 +Version ..........: 3.4 
-Manufacturer .....: unmanaged S/N range +Manufacturer .....: Nitrokey 
-Serial number ....: 43243711+Serial number ....: 6447F253
 Name of cardholder: Michael Nausch Name of cardholder: Michael Nausch
 Language prefs ...: de Language prefs ...: de
 Salutation .......: Mr. Salutation .......: Mr.
-URL of public key : [not set] +URL of public key : https://keys.openpgp.org/search?q=get&search=0x0A56C9A3A69FE291 
-Login data .......: [not set]+Login data .......: django
 Signature PIN ....: forced Signature PIN ....: forced
 Key attributes ...: ed25519 cv25519 ed25519 Key attributes ...: ed25519 cv25519 ed25519
 Max. PIN lengths .: 127 127 127 Max. PIN lengths .: 127 127 127
-PIN retry counter : 3 3 2 +PIN retry counter : 3 
-Signature counter : 23+Signature counter : 10
 KDF setting ......: off KDF setting ......: off
 UIF setting ......: Sign=off Decrypt=off Auth=off UIF setting ......: Sign=off Decrypt=off Auth=off
-Signature key ....: 2C08 2445 CDFB 72DE CD65  0350 610E D9AE E553 353F +Signature key ....: F5F0 CD13 074B A693 D950  F92A 0A56 C9A3 A69F E291 
-      created ....: 2024-01-03 21:17:32 +      created ....: 2024-12-15 17:08:38 
-Encryption key....: 9533 C548 589F F00B 8FFF  C93B B5E5 4345 BDA2 92A0 +Encryption key....: DBBD 5355 D9D0 334A A3FA  751F A89D D54D AE0E 394A 
-      created ....: 2024-01-03 21:17:32 +      created ....: 2024-12-15 17:08:38 
-Authentication key: D5AF 3627 1220 7A2A 54BD  6C47 C72E 74B8 1A5C 4549 +Authentication key: EE7C 3807 4F0A 8F2A 5601  BF91 1E61 4A9A 36D4 DF53 
-      created ....: 2024-01-03 21:17:32 +      created ....: 2024-12-15 17:08:38 
-General key info..: pub  ed25519/610ED9AEE553353F 2024-01-03 Django (Bastard Operator from Hell [BOfH]) <django@nausch.org> +General key info..: pub  ed25519/0A56C9A3A69FE291 2024-12-15 Michael Nausch <michael@nausch.org> 
-sec>  ed25519/610ED9AEE553353F  created: 2024-01-03  expires: never      +sec>  ed25519/0A56C9A3A69FE291  created: 2024-12-15  expires: never      
-                                card-no: FFFE 43243711 +                                card-no: 000F 6447F253 
-ssb>  ed25519/C72E74B81A5C4549  created: 2024-01-03  expires: never      +ssb>  ed25519/1E614A9A36D4DF53  created: 2024-12-15  expires: never      
-                                card-no: FFFE 43243711 +                                card-no: 000F 6447F253 
-ssb>  cv25519/B5E54345BDA292A0  created: 2024-01-03  expires: never      +ssb>  cv25519/A89DD54DAE0E394A  created: 2024-12-15  expires: never      
-                                card-no: FFFE 43243711 +                                card-no: 000F 6447F253</code>
-</code>+
  
 Ein erneuter Blick in die Prozessliste zeigt nun den neu gestarteten Agenten. Ein erneuter Blick in die Prozessliste zeigt nun den neu gestarteten Agenten.
    $ ps aux | grep gpg-agent    $ ps aux | grep gpg-agent
  
-  django    8766  0.0  0.0 364724   804 ?        Ss   21:57   0:00 gpg-agent --homedir /home/django/.gnupg --use-standard-socket --daemon +  django      1428  0.0  0.0 228968  4068 ?        SLsl 19:52   0:00 /usr/bin/gpg-agent --supervised 
-  django    8853  0.0  0.0 215740   828 pts/   S+   22:00   0:00 grep --color=auto gpg-agent+  django      5787  0.0  0.0   6392  2300 pts/   S+   20:32   0:00 grep --color=auto gpg-agent  
 + 
 +=== Public-Key des ED25519 SSH exportieren === 
 +Für den Zugriff auf unser Ziel-System mit Hilfe der SSH benötigen wir noch den öffentlichen Schlüssel unseres Authentication Keys, den wir nun exportieren werden. 
 +Zunächst besorgen wir uns die betreffende Schlüsselkennung des Authentication Keys, genauer gesagt die 4 letzten Zahlenreihen des nachfolgenden Aufrufs. 
 +   $ gpg2 --card-status | grep Authentication\ key 
 + 
 +  Authentication key: EE7C 3807 4F0A 8F2A 5601  BF91 1E61 4A9A 36D4 DF53 
 +In diesem Konfigurationsbeispiel ist die Schlüssel-ID des Autentication Keys also die Nummer ''**1E614A9A36D4DF53**''
 + 
 +Nun exportieren wir den öffentlichen Schlüssel und schreiben diesen in eine separate Datei. 
 +   $ gpg2 --export-ssh-key 1E614A9A36D4DF53 >> ~/.ssh/1E614A9A36D4DF53.pub 
 + 
 +Der Öffentliche Schlüssel in diesen Konfigurationsbeispiel lautet also: 
 +   $ cat ~/.ssh/1E614A9A36D4DF53.pub 
 + 
 +  ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILz8sjaPGlC16rOK7s8S8gzBmbfnCOsiz4jD77+BuLn4 openpgp:0x36D4DF53 
 + 
 +Diesen Schlüssel kopieren wir nun auf das entsprechende Zielsystem an Ort und Stelle ''**~/.ssh/authorized_keys**''
 +   $ scp ~/.ssh/1E614A9A36D4DF53.pub zielhost.dmz.nausch.org: && ssh zielhost.dmz.nausch.org 'cat authorized_keys >> ~/.ssh/authorized_keys' 
 + 
 +=== SSH-Verbindung aufbauen === 
 +Nun können wir wie gewohnt eine Verbindung zu unserem entfernten System aufbauen, sofern der GPG-Agent am laufen ist. Wir können dazu entweder erst einmal abfragen, ob dieser gestartet wurde, mit Hilfe des folgenden Aufrufs: 
 +   $ ps -aux | grep gpg-agent 
 + 
 +  django      1430  0.0  0.0 376092  3636 ?        SLsl 20:32   0:00 /usr/bin/gpg-agent --supervised 
 + 
 +Oder wir fragen einfach den Karten-Status ab, was unweigerlich den Neustart des GPG-Agenten nach sich zieht. 
 +   $ gpg2 --card-status 
 + 
 +Nun können wir die gewünschte Verbindung zum Zielsystem aufbauen. 
 +   $ ssh zielhost.dmz.nausch.org 
 + 
 +Da der SSH-Key zur Authentication nicht im Dateisystem liegt, sondern auf der SmartCard des Nitrokey werden wir nun nach der User-PIN gefragt, damit auf den privaten Schlüssel der Karte zugegriffen werden kann. 
 + 
 +{{ :nitrokey:arch:ssh_001.png?nolink&280 |Bild: PIN Abfrage beim Zugriff auf den Authentication Key der SmartCard des Nitrokeys}} 
 + 
 +Der entsperrte Schlüssel der SmartCard des Nitrokey Start wird nun im Speicher gehalten solange wir den USB-Hardwareschlüssel nicht abziehen.  
 + 
 +<WRAP center round important 90%> 
 +**WICHTIG:** \\ 
 +Da wir den Schlüssel **__nicht__** aus einer Datei geladen hatten, können wir diese auch nicht mit Hilfe von ''**ssh-add**'' wieder entladen! Wollen wir verhindern, dass auf den im Speicher vorgehaltenen Schlüssel zugegriffen wird, müssen wir manuell den GPG-Agenten beenden. 
 +   $ pkill gpg-agent 
 + 
 +</WRAP> 
 + 
 +Anschliessend lassen sich Verbindungen zu unseren Remote-Systemen erst wieder aufbauen, wenn der GPG-Agent geladen und die Karte nach Eingabe der PIN entsperrt wurde!
  
  • nitrokey/arch/3a.1734377298.txt.gz
  • Zuletzt geändert: 16.12.2024 19:28.
  • von django