6.3.1.20. SSH Keys

The token type sshkey is the public SSH key, that you can upload and assign to a user. The SSH key is only used for the application type SSH in conjunction with the Applications and Machines or Services concept.

A user or the administrator can upload the public SSH key and assign it to a user.

Paste the SSH key into the text area. The comment in the SSH key will be used as token comment. You can assign the SSH key to a user and then use the SSH key in Application Definitions SSH.

Note

This way you can manage SSH keys centrally, as you do not need to distribute the SSH keys to all machines. You rather store the SSH keys centrally in privacyIDEA and use privacyidea-authorizedkeys to fetch the keys in real time during the login process.

6.3.1.20.1. Reading the public key

Added in version 3.14.

The public SSH key is stored encrypted in the database and is therefore only contained in encrypted form in the token list. To retrieve the assembled public key (<type> <key> [<comment>]), use the endpoint GET /token/sshkey/<serial>. Access is guarded by the policy action sshkey_read in the scopes admin and user. A user may only read the SSH key of their own tokens.

Only active tokens hand out their key. Disabling or revoking an SSH key token stops the key from being read here, just like it stops the key from appearing in the authorized keys of a machine.

6.3.1.20.2. Integrity protection

Added in version 3.14.

The public SSH key is stored encrypted in the database. In addition, privacyIDEA stores an integrity checksum of the SSH key data (serial, key type, public key and comment) in the encrypted OTP key field of the token. The checksum is verified whenever the SSH key is fetched. This way a manipulation of the database entries - e.g. a database administrator replacing the public key to gain access to SSH servers - is detected and the SSH key is not handed out. When an SSH server fetches the keys of several tokens, e.g. through privacyidea-authorizedkeys, only the key of such a token is left out and the error is written to the log file; the keys of the other tokens are still handed out.

The checksum covers the SSH key data wherever privacyIDEA writes it, e.g. during enrollment and import. The generic token info endpoint (POST /token/info/<serial>/<key>) refuses the keys ssh_key, ssh_type and ssh_comment, and POST /token/set ignores them; to change the key or its comment, enroll the token again.

Note

SSH key tokens enrolled with privacyIDEA versions before 3.14 get their checksum computed by the database migration during the update. If the checksum is missing (e.g. the migration was not run), the token will refuse to hand out the SSH key.

Note

A token whose checksum is present but unreadable is reported as possibly corrupted rather than as unmigrated - rerunning the migration would not repair it. Such a token, and one that lost its public key, keeps refusing to hand out the SSH key until it is re-enrolled.

6.3.1.20.3. Allowed key types

By default the following SSH key types can be enrolled:

  • ssh-rsa

  • ssh-ed25519

  • ecdsa-sha2-nistp256

  • sk-ecdsa-sha2-nistp256@openssh.com

  • sk-ssh-ed25519@openssh.com

Additional key types can be allowed with the configuration entry PI_ALLOWED_SSH_KEY_TYPES in pi.cfg, see Allowed SSH key types.