SSH CA
Instead of copying public keys to hosts, technicians log in with short-lived SSH certificates that the dashboard has the gateway sign. A host trusts one certificate authority (CA); who may log in where, as which login name and for how long is decided in the dashboard, and every certificate is written to the audit log.
There are two CAs, both held by selvara-gateway and never by the dashboard:
- the user CA signs certificates for people. Hosts trust it with sshd's
TrustedUserCAKeys. - the host CA signs certificates for hosts. The command line trusts it, so a changed host key is noticed instead of clicked away.
Both need a configured gateway (GATEWAY_URL and GATEWAY_TOKEN). Without
one the pages explain that nothing can be installed or issued.
Putting the CA on hosts
Access → SSH CA lists every host with its state and shows the public keys
of both CAs with their fingerprints. Select hosts and choose Install user
CA, Issue host certificates, or both. Administrators and managers may
do this, and the person needs the service permission for the customer, because
the work is a job of the types sshca.install and sshca.host-cert.
Under a customer access policy that requires approval these jobs wait for approval
like any other.
A host takes part only when its config.yaml lists ssh-ca under actions
(see Agent Installation). The page says
"The host's configuration does not allow ssh-ca" otherwise. Windows hosts are
not supported.
What the user CA job does on a host
- Writes the CA's public key to
/etc/ssh/selvara_user_ca.pub. - Writes one file per login name under
/etc/ssh/selvara_principals/, so thatsshdaccepts a certificate for the loginadminonly when it carries the principaladmin@<system id>: the certificate names the host it was issued for, and no other host accepts it. Without a principal map every account with a login shell gets such a file, so an account created later logs in with a certificate after the job has run again. A map in the job's parameters lists the logins and principals instead; it may not namerootorAdministratorwhile the gateway denies them. - Adds
TrustedUserCAKeysandAuthorizedPrincipalsFileto the configuration: as a drop-in file insshd_config.d/whensshd_configincludes that directory, otherwise as a marked block (# BEGIN selvara user-cato# END selvara user-ca) insshd_config. - Checks the result with
sshd -t, then reloadssshd. When either step fails every file is put back exactly as it was and the job reports the reason.
Existing keys and sessions keep working. A host that already trusts a
different CA through TrustedUserCAKeys, or maps principals with its own
AuthorizedPrincipalsFile, is refused instead of overridden: sshd honours
the first such line it reads, so the Selvara line would silently displace the
one the host depends on. Merge the keys by hand or remove that line, then
install again.
The job can be run again at any time; it is how a changed policy reaches the hosts, and how a rotated CA key is replaced (the state shows Outdated).
Host certificates
The host holds its keys and only the gateway signs, so the certificate takes
two jobs: the host reports its public keys, the dashboard has them signed for
the name <system id>.selvara.invalid (chosen by the dashboard, not by the
host, so a host cannot ask for a certificate in the name of another), and the
host stores the certificates next to its keys and adds HostCertificate
lines. Host certificates are valid for 90 days. The page shows when each ends
and flags those with less than 14 days left; run Issue host certificates
again to renew them. Hosts keep their keys.
selvara ssh-config writes @cert-authority entries for the host CA into the
known hosts file the command line uses, so a host with a certificate is
trusted by its certificate and one whose key changed without a new certificate
is refused. See CLI.
Access policies
Settings → Access and rights → Access policies lists the customers; Certificate rules on a row opens the rules of that customer. A rule says:
| Field | Meaning |
|---|---|
| Accounts and roles | Who it covers. Either list matches; both empty means every account that may open shells at the customer. |
| Hosts and tags | Which hosts. Either list matches; both empty means every host of the customer. |
| Login names | The principals the certificate carries, for example admin, and root for administrators. 1 to 8 plain names. |
| Maximum validity | Up to 8 hours, which is also the most the gateway signs. Default 8 hours. |
Whether a request needs approval (four eyes) or a reason is not a property of a rule. It comes from the customer's own access policy, so it applies to everyone at that customer alike. The customer's SSH certificate validity is a second cap: a certificate lasts at most the shortest of the gateway's 8 hours, the customer's cap and the maximum of every rule that covers the account on the host.
Without a rule nobody gets a certificate: a customer starts closed. When several rules cover one account on one host, the login names are the union and the shortest validity wins. A broad rule therefore never loosens a narrow one.
Rules written before 3.5.0 could require approval or a reason themselves. Upgrading folded those into the customer, see Upgrading to 3.5.0.
Getting a certificate
The command line asks POST /api/access/ssh-cert with its public key and the
host id; ssh calls it for you through selvara proxy. The dashboard
checks, in this order:
- the account may open shells at the customer (
access.shell), and the host is an approved agent; - a policy covers the account on the host;
- where a policy wants a reason or approval, an open request exists and is approved;
- if the account has a second factor, it was verified in the last 8 hours: either by the sign-in the command line did, or by a code sent along;
- the account is not asking too often.
Then the gateway signs. The certificate is valid for the shortest of the
policy's maximum, the end of the approval and the age of the second factor,
and never for less than a minute. Refusals carry a reason the command line
turns into advice: no_policy, access_request_required,
access_request_pending, second_factor_required, grant_expired and
others. Refusals are audited as denied.
Access requests
Where a policy wants approval or a reason, run
selvara request-access acme/web-01 --reason "patch window" or request access
in Access → Requests.
- A request that needs only a reason is granted at once.
- A request that needs approval waits for someone else who may open shells or tunnels at the customer. Nobody can approve or deny their own request.
- One approval covers every way into the host: SSH certificates, browser shells and tunnels. Where the customer requires approval, opening a shell or a tunnel files the request itself.
- Approvers see pending requests live, with the reason, and may add a note. Approval grants access for the requested time, at most the policy's maximum. The requester can withdraw a request.
- A request nobody decides lapses after 24 hours. An approval ends at its time. Neither is a stored state; the page shows them as expired and ended.
- A browser shell or tunnel opened under an approval lasts at most until the approval ends, and the shorter of the customer's certificate cap and the rule's maximum validity bounds one that needs no approval. Withdrawing an approved request ends the shells and tunnels opened under it.
- A customer that requires a reason applies to all three ways in: the reason has to be at least three characters, and a request that needs approval is not filed without one.
Requests, decisions, certificates and installations are audited:
access_request (create, decide, cancel), access_policy (create, update,
delete), ssh_cert.issue, and ssh_ca (install, host certificates). A
certificate's audit entry names the policies, principals, key fingerprint and
request that allowed it.
Troubleshooting
- No certificate rule allows this account: add a rule for the customer that covers the account and the host.
- Certificate accepted but login refused:
sshdmaps principals per login name and host. Check that the rule's login names include the one you use, then install the user CA again to refresh the mapping. After an upgrade from a release whose certificates carried plain login names, install the user CA again on every host: until then its certificates are refused. - Host already trusts another certificate authority: see above; the host is left unchanged.
- Rotated CA key: install the user CA on all hosts again, and issue the host certificates again; the page marks the hosts that still carry the old key.