Page MenuHomeVyOS Platform

Add support for SSH certificate configuration
Closed, ResolvedPublicFEATURE REQUEST

Description

Overview

In a typical system with OpenSSH, the TrustedUserCAKeys and AuthorizedPrincipalsFile options can be used to permit SSH certificates to login to systems.

This request is to request the ability to configure the SSH server configurations needed to make SSH certificates work with VyOS.

Our background regarding this request is the ability to use SSH certificates to login to our VyOS hosts instead of fixed SSH keys or fixed passwords. The ability to login with certificates allows for keys to have a limited lifespan that is not tied to the device's configuration.

Examples

Mapped to a file containing principal names, configured by sshd_config AuthorizedPrincipalsFile.

# set service ssh trusted-user-ca-key <location>
  • <location> can be a local path or a URL pointing at a remote file.
  • Example (Local): set service ssh trusted-user-ca-key /tmp/ssh-ca.pem
  • Example (Remote): set service ssh trusted-user-ca-key https://example.com/ssh-ca.pem

Mapped to sshd_config TrustedUserCAKeys.

# set system login user <username> authentication ca-principals <principal-name>
  • Adds a SSH certificate principal for a given user for authentication. Multiple principals are permitted for users.
  • Example: add system login user vyos authentication ca-principals netadmins

Details

Version
-
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)

Event Timeline

Viacheslav triaged this task as Wishlist priority.Feb 5 2024, 8:10 AM

hi,I am interested in this issue and would like to work on it.
If there are any relevant code references or examples, please let me know.

Viacheslav changed the task status from Open to In progress.Dec 12 2024, 9:05 AM
Viacheslav assigned this task to takehaya.

I’ve made various improvements to the code based on the feedback from the review and have moved things forward.
Could you let me know how I can proceed to get further reviews on this PR? 😊

Hi.
The CLI smoketests are failing due to changes unrelated to this PR. I checked the "current" branch and found that the same issue occurs there as well, so it seems that it cannot be resolved unless it is addressed separately.
I believe there are no issues with this PR itself, so I would like it to be merged. What do you think?
I have already received a review and approval.

Thank you for merging the PR! I plan to work on the AuthorizedPrincipalsFile support next. I look forward to your continued support:)

Viacheslav changed the task status from In progress to Needs testing.Dec 23 2024, 2:30 PM

I have added what you included this time to the documentation. It's a simple update, but please review it.

https://github.com/vyos/vyos-documentation/pull/1578

Hello @takehaya,

Thank you for the feature; I really appreciate it.

I'm having trouble making it work and would gladly accept any assistance. From what I understand, the procedure is as follows:

  1. Add a certificate authority using the PKI module: `bash set pki ca <ca_name> certificate `
  2. Reference the CA in the SSH service: `bash set service ssh trusted-user-ca-key ca-certificate <ca_name> `

The issue I'm facing is that my SSH CA public key is in the .pub format (ssh-rsa AAAAB3...), which is standard for SSH, rather than the .pem format (-----BEGIN [something]-----) required by VyOS PKI.

I tried converting the .pub key to .pem, but I encountered the following error:

[pki]  
Invalid certificate on CA certificate "vault"  
[[pki]] failed  

[service ssh]  
Traceback (most recent call last):  
  File "/usr/libexec/vyos/services/vyos-configd", line 138, in run_script  
    script.generate(c)  
  File "/usr/libexec/vyos/conf_mode/service_ssh.py", line 133, in generate  
    ca_full_chain = find_chain(loaded_ca_cert, loaded_ca_certs)  
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3/dist-packages/vyos/pki.py", line 451, in find_chain  
    parent = find_parent(chain[-1], remaining)  
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3/dist-packages/vyos/pki.py", line 442, in find_parent  
    if verify_certificate(cert, ca_cert):  
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
  File "/usr/lib/python3/dist-packages/vyos/pki.py", line 363, in verify_certificate  
    if ca_cert.subject != cert.issuer:  
       ^^^^^^^^^^^^^^^  
AttributeError: 'bool' object has no attribute 'subject'  

[[service ssh]] failed  
Commit failed

For additional context, I am using Vault’s SSH secret engine for fully automated credential management.

c-po moved this task from Backlog - Feature Requests to Completed on the VyOS Rolling board.

@tarik.haddouchi I just merged the changes into current and thus will be in the next rolling release. I also encountered this weirdness. CA keys have been moved to OpenSSH public/private keys, see updated documentation: https://docs.vyos.io/en/latest/configuration/service/ssh.html

dmbaturin renamed this task from SSH Certificate configuration to Add support for SSH certificate configuration.Jul 9 2025, 1:01 PM
dmbaturin changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.