Skip to content

Commit 94a624a

Browse files
ABuljkodaringer
authored andcommitted
Docs: update SSH Authentication (ssh.rst)
1 parent 5e7b535 commit 94a624a

File tree

1 file changed

+23
-27
lines changed
  • source/components/nitrokeys/features/fido2

1 file changed

+23
-27
lines changed

source/components/nitrokeys/features/fido2/ssh.rst

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,33 @@ Generating SSH Key
1212

1313
1. Insert the Nitrokey into your computer.
1414

15-
2. Open a terminal and execute the following command, replacing "your_comment" with a note to identify your key (e.g., "Nitrokey GitLab"). The -C "your_comment" parameter is optional — it only adds a label for identification (e.g., in GitLab or GitHub), and the command will work normally without it.
15+
2. Open a terminal and create your SSH key. Replace ``"your_comment"`` with a label to identify it (e.g., "Nitrokey GitLab").
16+
By default, the key is a non-resident key, meaning a local key handle is stored in ``~/.ssh/`` while the private key remains securely on the Nitrokey.
17+
Use the ``-O resident`` option if you want the key to be portable across systems.
1618

1719
.. code-block:: shell-session
1820
1921
ssh-keygen -t ed25519-sk -C "your_comment"
2022
21-
3. You can optionally create a resident key, allowing it to be used on other computers without copying files. By default, SSH FIDO2 keys created with -t ed25519-sk are non-resident, meaning a local key handle is stored in ~/.ssh/ while the private key remains securely on the Nitrokey. Using -O resident provides portability across systems, but for single-system use, the standard ssh-keygen -t ed25519-sk command is sufficient.
22-
23+
or to create a resident key
24+
2325
.. code-block:: shell-session
2426
2527
ssh-keygen -t ed25519-sk -O resident -C "your_comment"
2628
27-
.. note::
29+
.. warning::
2830

29-
On a new system you can list and load resident keys from the device with:
31+
The ``-O resident`` option stores key handles on the Nitrokey, allowing others with physical access to list them and see where the key was used.
3032

33+
.. note::
34+
35+
Resident keys can later be listed and imported on another system with:
36+
3137
.. code-block:: shell-session
3238
3339
ssh-keygen -K
3440
41+
3542
4. 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 key files. Using both increases overall security.
3643

3744
5. When asked for a file path, accept the default option (``~/.ssh/id_ed25519_sk``) or choose a custom name like ``id_ed25519_sk_gitlab``.
@@ -55,34 +62,23 @@ Generating SSH Key
5562
Adding Your Public Key
5663
----------------------
5764

58-
1. Once your SSH key pair is generated, the public key must be added to the service or server you want to access.
65+
Once your SSH key pair is generated, the public key must be added to the service or server you want to access.
5966

60-
1.For Git Services (GitLab, GitHub, etc.)
61-
1. Display your public key:
67+
For Git Services (GitLab, GitHub, etc.)
6268

63-
.. code-block:: shell-session
64-
65-
cat ~/.ssh/id_ed25519_sk.pub
69+
1. Display your public key:
6670

67-
Example output (do not use this key)::
68-
69-
[email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG7wZW4zc2guY29tAAAAILeZl6r07HV4i1rK07OfLqD3J4IzX2q0lB6Ok0pdxoG5AAAABHNzaDo= your_comment
71+
.. code-block:: shell-session
7072
71-
2. Copy the output and add it to your account’s SSH key settings.
72-
See `GitLab <https://docs.gitlab.com/user/ssh/#add-an-ssh-key-to-your-gitlab-account>` or `GitHub <https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account>` for detailed steps.
73+
cat ~/.ssh/id_ed25519_sk.pub
7374
75+
Example output (do not use this key)::
76+
77+
[email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG7wZW4zc2guY29tAAAAILeZl6r07HV4i1rK07OfLqD3J4IzX2q0lB6Ok0pdxoG5AAAABHNzaDo= your_comment
7478

75-
2. To allow SSH access to the remote servers, the same public key must be listed in the server’s ``~/.ssh/authorized_keys`` file. During authentication, the server checks for a matching key and verifies your identity through a challenge signed by your Nitrokey’s private key.
76-
To add your key:
79+
2. Copy the output and add it to your account’s SSH key settings.
7780

78-
.. code-block:: shell-session
81+
See `GitLab <https://docs.gitlab.com/user/ssh/#add-an-ssh-key-to-your-gitlab-account>` or `GitHub <https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account>` for detailed steps.
7982

80-
mkdir -p ~/.ssh
81-
chmod 700 ~/.ssh
82-
cat ~/.ssh/id_ed25519_sk.pub >> ~/.ssh/authorized_keys
83-
chmod 600 ~/.ssh/authorized_keys
8483

85-
Each line in ``authorized_keys`` represents one trusted key.
86-
87-
You can add multiple keys or restrict usage, for example to a specific IP range and command:
88-
from="192.168.0.*" command="/usr/local/bin/backup.sh" [email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG7wZW4zc2guY29tAAAAILeZl6r07HV4i1rK07OfLqD3J4IzX2q0lB6Ok0pdxoG5AAAABHNzaDo= your_comment
84+
To enable SSH remote server access, add your public key (from ``~/.ssh/id_ed25519_sk.pub``) to the ``~/.ssh/authorized_keys`` file of the user account. This allows passwordless authentication using your Nitrokey.

0 commit comments

Comments
 (0)