Skip to content

Houseguest certificates

With Houseguest certificates, a viewer signed in to a preview opens the browser terminal on an SSH server and is signed in to it with no password or key of their own. Houseguest™ signs a short-lived SSH certificate for that one connection, in the viewer’s name. The server trusts your workspace’s certificate authority once, with one line of sshd_config.

  • No shared passwords or keys. Nobody hands a server password or private key to a reviewer, and nothing has to be collected or changed afterwards.
  • Each person is named on the server. Every certificate carries the viewer’s email address, so the server’s own log says who signed in, not just the account.
  • Access ends with the preview. Only a viewer signed in to an open preview gets a certificate, and each one is good for 5 minutes. Revoke someone or end the preview and they get no more; their open sessions close within 15 seconds.
  • One setup per server. Trust the authority once; every later preview, viewer and username works without touching the server again.
  1. Your workspace has its own SSH certificate authority, made the first time a service allows certificates. Its private key stays sealed in the workspace’s data and never reaches an edge.
  2. A viewer opens the browser terminal, chooses Houseguest certificate and enters an allowed username.
  3. The edge makes a one-time key for this connection, and Houseguest checks the viewer’s sign-in to the preview, the service and the username before signing a certificate for that key.
  4. The edge signs in to the server with it. The one-time key is discarded with the connection.

Each certificate:

Signs in as One username, from the list the sharer allowed, and only one the agent lists for that server (below)
Valid 5 minutes, for signing in. A session that is already open is not cut when the certificate expires
Key ID hg:<workspace>:<viewer's email>:<preview id>, for example hg:acme:[email protected]:k3x7q2m5w4p5r6t2
Allows A terminal only: no agent, port or X11 forwarding

The agent that reaches a server decides which usernames a certificate may ever name for it. In the agent’s HG_ALLOW_TCP, end the server’s entry with ;users= and the accounts, separated by + (agent 0.8.0 or later):

Terminal window
HG_ALLOW_TCP='build-01.lab.example.com:22=10.0.0.21:22;users=ops+deploy,db.lab.example.com:5432=10.0.0.30:5432'
  • A server without users= gets no certificates at all.
  • Nobody in the console or the API can set a username the agent does not list, and Houseguest checks the list again each time it signs, so removing a name from the agent stops it at once. Open sessions signed in as it close within 15 seconds.
  • root works only if you list it.
  • When several agents offer the same server name, a certificate connection goes only through an agent that lists the username for it. Another agent listing root for the same name never lets a certificate for root through one that lists only ops. The console accepts a username that any agent seen in the last 10 minutes lists; an agent stopped for longer no longer counts.
  • Quote the value: ; ends a shell command. The installer takes the same value: --allow-tcp 'build-01.lab.example.com:22=10.0.0.21:22;users=ops'.
  • An agent before 0.8.0 does not start with users= in the list. Update the agent first (Update an agent).

The preview’s TCP & SSH tab names the usernames the agent allows for each SSH service, or says to set users= when it lists none.

Once a service of a preview allows certificates (next section), the preview’s TCP & SSH tab shows a Houseguest certificates card with the authority’s public key and the line for sshd_config, each with Copy. The same key serves every preview and every server of the workspace.

On the SSH server (OpenSSH), as root:

  1. Save the public key line as /etc/ssh/houseguest_ca.pub:

    Terminal window
    echo 'ssh-ed25519 AAAA… houseguest-ca:acme' > /etc/ssh/houseguest_ca.pub
  2. Add the line to /etc/ssh/sshd_config (or a file in /etc/ssh/sshd_config.d/ where the main file includes that folder, as on Ubuntu and Debian):

    TrustedUserCAKeys /etc/ssh/houseguest_ca.pub
  3. Check the configuration and reload the SSH server:

    Terminal window
    sshd -t && systemctl reload ssh

    The service is called sshd on some systems (systemctl reload sshd).

The account viewers sign in as (ops here) must exist on the server and must not be locked. On Alpine, adduser -D leaves the account locked, and the server then refuses every key: give it a password, or set the password field to *.

The server’s clock must be right: a certificate is valid from a minute before it is signed, so a server clock more than a minute slow or five minutes fast refuses it.

Section titled “Limit which accounts take certificates (recommended)”

Without more configuration, a certificate signs in as the username it names, on any account of the server. The agent’s users= already limits what Houseguest signs; this adds the server’s own say, so even a certificate for another username would not sign in. To list for each account the certificate usernames it accepts, add to sshd_config:

AuthorizedPrincipalsFile /etc/ssh/auth_principals/%u

and list the usernames, one per line, in a file named after the account:

Terminal window
mkdir -p /etc/ssh/auth_principals
echo ops > /etc/ssh/auth_principals/ops

An account without a file then takes no Houseguest certificate.

On the preview’s TCP & SSH tab, each SSH service (port 22) has Browser terminal sign-in:

Choice Viewers
Their own password or key (default) Enter a username and a password or private key
Houseguest certificate Enter only an allowed username
Either Choose one of the two

With Houseguest certificate or Either, fill in Usernames: the accounts on the server viewers may sign in as, up to 10, separated by commas or spaces (letters, digits, ., _ and -, at most 32 characters each), each one the agent lists in users=. Press Save. A username the agent does not list is not saved: Not saved: root is not in users= for ssh.lab.example.com:22 in the agent's HG_ALLOW_TCP (it allows ops). Both choices are unavailable while the agent lists none for the service. The console confirms, for example: Viewers can sign in to ssh.lab.example.com:22 with a Houseguest certificate as ops. The server must trust the workspace's certificate authority.

Changing the setting needs the Add TCP services permission on the preview, like adding the service; without it, the row shows the setting as text. It is available on every plan that includes TCP services. The setting applies to the browser terminal and the terminals page; the houseguest command line always uses the viewer’s own SSH keys.

A script can do the same with the API: see SSH-only preview from a script.

A service set to Houseguest certificate can also have a start command with Mode Command only. Each certificate for that service then carries the command as the force-command critical option, and OpenSSH runs it, and nothing else, whatever the client asks for: the same effect as ForceCommand in sshd_config, but set per service in Houseguest and only for Houseguest certificates. Nothing else in the certificate changes: the username, the 5-minute validity and the key ID stay as they are. Certificates for the service’s other previews, and for other services, carry no command: the setting restricts that service of that preview, not the server. Another preview with the same server, or another name the agent allows for it, can still open a shell.

In the browser terminal, Houseguest certificate appears beside Password and Private key, or alone when the service takes certificates only. The viewer enters the username, filled in when only one is allowed, and presses Connect. The page says what happens: Houseguest signs a certificate for this connection only, valid 5 minutes, in the viewer’s name.

On the terminals page, each server that allows it offers Houseguest certificate under Sign in with. When every server takes certificates only, the page asks for no password or key at all.

On the server, OpenSSH logs the certificate’s key ID with each sign-in, similar to:

Accepted publickey for ops from 10.0.0.5 port 51514 ssh2: ED25519-CERT SHA256:… ID hg:acme:[email protected]:k3x7q2m5w4p5r6t2 (serial …) CA ED25519 SHA256:…

The address is the agent’s host, for every viewer; the key ID tells them apart. The viewer’s email address is therefore written to the server’s log.

In Houseguest, each certificate appears in the preview’s Requests as Houseguest certificate issued, and in the Activity log as SSH certificate issued, with the username and key ID. Key material is never recorded.

  • One certificate authority per workspace. It cannot be rotated yet: the same public key stays valid for the workspace. The agent’s users= and, on the server, AuthorizedPrincipalsFile keep a certificate to the accounts you meant for it.
  • At most 10 certificates a minute for one viewer.
  • A certificate is issued only after the server’s host key checks out: a server whose key changed gets none until the viewer confirms the new key.
  • Certificates are for the browser terminal only.
  • A certificate allows a terminal session only; port forwarding and agent forwarding are refused.
The viewer sees Cause and fix
The server refused the Houseguest certificate for that username. The certificate was issued, but the server did not accept it: the server does not trust the authority yet (check the file path and that the SSH server was reloaded), the account does not exist or is locked, AuthorizedPrincipalsFile does not list the username, or the server’s clock is wrong. The server’s log says which: journalctl -u ssh (or -u sshd), or /var/log/auth.log
That username is not allowed for this server. Use one of the usernames in Usernames, or add it there (it must also be in the agent’s users=)
This server does not accept Houseguest certificates. The service is set to Their own password or key, or the agent lists none of its usernames in users=
This server takes Houseguest certificates only, and none can be issued for it now. The agent lists none of the service’s usernames: add them to users= in its HG_ALLOW_TCP (agent 0.8.0 or later)
Refused: too many Houseguest certificates in the last minute. Try again in a minute. More than 10 sign-ins a minute; wait a minute
This server accepts Houseguest certificates only. The service is set to Houseguest certificate: choose it instead of a password or key
Houseguest certificates are unavailable right now. The edge cannot sign certificates at the moment. Try again, or contact us
Not signed in to this preview, or the sign-in has ended. Sign in to the preview again

In the console, No Houseguest certificates for this service: set users= for it in the agent’s HG_ALLOW_TCP means the agent lists no usernames for that server (above). Houseguest certificates are unavailable on this server. under the setting means the server that signs holds no key for certificate authorities. On a self-hosted edge, the installer creates that key.