SSH Authentication with FIDO2

Compatible Nitrokeys

3A/C/Mini

Passkey

HSM 2

Pro 2

FIDO2

Storage 2

Start

U2F

active

active

inactive

inactive

active

inactive

inactive

inactive

SSH (Secure Shell) is a network protocol used to securely access and manage remote systems such as servers or code repositories. It uses cryptographic key pairs for authentication, allowing passwordless logins with strong security.

With a Nitrokey, the private SSH key is generated and stored directly on the device, so it never leaves the hardware. Each login requires you to touch the Nitrokey, adding a simple physical confirmation that protects against unauthorized access. For example, when connecting to a server, GitLab, or GitHub.

Non-Discoverable Credentials

Neatklājams akreditīvs ir noklusējuma akreditīva tips, kas izveidots, kad lietotājs reģistrē savu Nitrokey autentifikācijas sistēmā, kas atbalsta FIDO2/WebAuthn. Autentifikācijas sistēma glabā atslēgas rokturi, bet privātā atslēga paliek droši Nitrokey. Šī konfigurācija neizmanto Nitrokey glabāšanas vietu un ir atkarīga no autentifikācijas sistēmas, kas nodrošina atslēgas rokturi pieteikšanās laikā. FIDO2 PIN kontrolē piekļuvi Nitrokey un autorizē visas darbības, kas saistītas ar privātajām atslēgām.

Discoverable Credentials

Atrodamais akreditācijas dokuments tiek saglabāts tieši Nitrokey, ieskaitot visu autentifikācijai nepieciešamo akreditācijas informāciju un metadatus. Tas ļauj autentifikācijas sistēmai automātiski atrast akreditīvu, nenorādot ārējo atslēgas rokturi, un ļauj veikt autentifikāciju bez lietotājvārda. Atrodamās akreditācijas ir aizsargātas ar FIDO2 PIN kodu, kas autorizē to izmantošanu un nodrošina, ka tām var piekļūt tikai autorizēts lietotājs. Katrs akreditīvs parasti aizņem dažus simtus baitu drošā atmiņā. Kopējais pilnvaru skaits ir atkarīgs no Nitrokey modeļa un programmaparatūras versijas, parasti tas ir no 25 līdz 100 ierakstiem.

Generating SSH Key

  1. Insert the Nitrokey into your computer.

  2. Open a terminal and create your SSH key. Replace "your_comment" with a label to identify it (e.g., „Nitrokey GitLab“). By default, the key is created as a non-discoverable credential. In this case, a local key handle is stored in ~/.ssh/ while the private key remains on the Nitrokey. This means the key is tied to the system where it was generated, since the local key handle file is required for authentication. Use the -O resident option to create a discoverable credential. In this case, the credential is stored on the Nitrokey, making it portable and usable across different systems without copying any local files.

    Non-discoverable credential:

    ssh-keygen -t ed25519-sk -C "your_comment"
    

    Discoverable credential:

    ssh-keygen -t ed25519-sk -O resident -C "your_comment"
    

    Piezīme

    Discoverable credentials can later be listed and imported on another system with:

    ssh-keygen -K
    
  3. During key generation, you may also be asked to set a passphrase. This passphrase encrypts the local key handle stored in ~/.ssh/ (not the private key on the Nitrokey, which always stays securely inside the device). The passphrase is different from the FIDO2 device PIN. The PIN protects the physical key itself, while the passphrase protects your local SSH public key file. We recommend to use a passphrase to protect non-discoverable keys only.

  4. Kad tiek prasīts norādīt faila ceļu, pieņemiet noklusējuma opciju (~/.ssh/id_ed25519_sk) vai izvēlieties pielāgotu nosaukumu, piemēram, id_ed25519_sk_gitlab.

  5. Ja Nitrokey mirgo, apstipriniet darbību, pieskaroties tam.

  6. Galu galā tiks izveidoti šādi faili. Failu nosaukumi var atšķirties, ja, ģenerējot atslēgu, esat norādījis pielāgotu nosaukumu.

    ~/.ssh/id_ed25519_sk → privātā atslēgas rokturis (droši glabājas Nitrokey).

    ~/.ssh/id_ed25519_sk.pub → publiskās atslēgas fails

    attēls0

Adding Your Public Key

Kad SSH atslēgu pāris ir izveidots, publiskā atslēga jāpievieno pakalpojumam vai serverim, kuram vēlaties piekļūt.

  1. Display your public key:

    cat ~/.ssh/id_ed25519_sk.pub
    

    Izvades piemērs (neizmantojiet šo atslēgu):

    sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG7wZW4zc2guY29tAAAAILeZl6r07HV4i1rK07OfLqD3J4IzX2q0lB6Ok0pdxoG5AAAABHNzaDo= your_comment
    
  2. Nokopējiet rezultātu un pievienojiet to sava konta SSH atslēgas iestatījumiem.

    See GitLab or GitHub for detailed steps.

    Lai iespējotu SSH attālināto piekļuvi serverim, pievienojiet savu publisko atslēgu failam ~/.ssh/authorized_keys savā SSH servera lietotāja kontā.