SSH Key and Certificate Management

The CLI manages SSH public keys and short-lived certificates for secure Space entry. For both Space admins and Space members, the default command is spaces connect. The typical flow is:

  1. Connect to a Space with connect.
  2. The CLI ensures a dedicated local SSH key exists, registers that public key if needed, fetches pinned host trust material, issues a short-lived certificate, and invokes ssh.

Most users should stop there. For advanced use, you can still register keys manually with ssh add-key, issue certificates manually with ssh issue-cert, or generate an OpenSSH config block with ssh client-config.

Certificates default to a 5-minute TTL, keeping the attack surface minimal.

Test harness -- in normal use, just run "spaces" directly.
. .specdown/test-env tmp=$(mktemp -d) spaces_issue_auth_key alice@example.com admin > "$tmp/auth.key" chmod 600 "$tmp/auth.key" cat > "$tmp/spaces" <<WRAPPER #!/bin/sh export SPACES_BASE_URL=$SPACES_BASE_URL : "\${SPACES_SESSION_FILE:=$tmp/session.json}" export SPACES_SESSION_FILE exec $SPACES "\$@" WRAPPER chmod +x "$tmp/spaces" "$tmp/spaces" login alice@example.com --key-file "$tmp/auth.key" >/dev/null ssh-keygen -q -t ed25519 -N '' -f "$tmp/id_ed25519" printf '%s\n' "$tmp/spaces" "$tmp"
cli=/tmp/tmp.JMUzUK9pQE/spaces, tmp=/tmp/tmp.JMUzUK9pQE
rm -rf ${tmp}

Registering SSH Keys

Add a key

Register your SSH public key with a friendly name:

$ /tmp/tmp.JMUzUK9pQE/spaces ssh add-key --name my-laptop --public-key-file /tmp/tmp.JMUzUK9pQE/id_ed25519.pub
registered ssh key SHA256:fake1
$cli=/tmp/tmp.JMUzUK9pQE/spaces, $tmp=/tmp/tmp.JMUzUK9pQE

You can also pass the key material inline with --public-key instead of --public-key-file.

List registered keys

$ /tmp/tmp.JMUzUK9pQE/spaces ssh list-keys | awk '{print $1, $2, $3}'
id name fingerprint 1 my-laptop SHA256:fake1
$cli=/tmp/tmp.JMUzUK9pQE/spaces, $tmp=/tmp/tmp.JMUzUK9pQE

Remove a key

Unregister a key by its fingerprint:

$ /tmp/tmp.JMUzUK9pQE/spaces ssh remove-key --fingerprint SHA256:fake1
removed ssh key SHA256:fake1
$cli=/tmp/tmp.JMUzUK9pQE/spaces, $tmp=/tmp/tmp.JMUzUK9pQE

Connecting to a Space

Quick connect

connect is the easiest way to enter a Space. It handles certificate issuance automatically. If you omit SPACE, the CLI uses your saved default Space, or the only visible Space when exactly one is available. When you want to override that choice, pass either the Space ID (e.g. sp_xxx) or the exact Space name when that name is unique among your visible Spaces:

spaces connect
spaces connect my-project
spaces ssh connect --space my-project

Behind the scenes, the CLI:

  1. Ensures a dedicated local private key exists (defaults to ~/.ssh/id_ed25519_spaces)
  2. Registers the matching public key if the control plane has not seen it yet
  3. Fetches a pinned known_hosts line for the SSH entry host
  4. Sends the public key to the control plane to get a short-lived certificate
  5. Writes the certificate next to the private key
  6. Runs ssh with strict host-key checking, the certificate, the identity file, and the Space target

That means a member who has already run spaces login you@example.com usually does not need to think about ssh add-key, ssh list-keys, ssh remove-key, or ssh issue-cert at all.

OpenSSH config

If you prefer to use ssh directly, generate an OpenSSH config block and paste it into ~/.ssh/config. The CLI rejects client-config inputs that contain whitespace or control characters, because those values would change the meaning of the generated ssh_config directives:

$ /tmp/tmp.JMUzUK9pQE/spaces ssh client-config --space sp_1 --identity-file /tmp/tmp.JMUzUK9pQE/id_ed25519 --host cell.example.com | grep -E 'HostName|StrictHostKeyChecking'
HostName cell.example.com StrictHostKeyChecking yes
$cli=/tmp/tmp.JMUzUK9pQE/spaces, $tmp=/tmp/tmp.JMUzUK9pQE

After adding this to your SSH config, you can connect with just ssh spaces-sp_1.

Manual Certificate Issuance

For scripting or debugging, you can issue a certificate without connecting:

$ /tmp/tmp.JMUzUK9pQE/spaces ssh issue-cert --identity-file /tmp/tmp.JMUzUK9pQE/id_ed25519 | head -1
issued ssh certificate /tmp/tmp.JMUzUK9pQE/id_ed25519-cert.pub
$cli=/tmp/tmp.JMUzUK9pQE/spaces, $tmp=/tmp/tmp.JMUzUK9pQE

The certificate is written next to the private key:

$ test -f /tmp/tmp.JMUzUK9pQE/id_ed25519-cert.pub && echo exists
exists
$cli=/tmp/tmp.JMUzUK9pQE/spaces, $tmp=/tmp/tmp.JMUzUK9pQE