Skip to content

ssh, ssh-config

See Connect over SSH for the full picture.

space ssh

space ssh <machine> [<ssh options>…] [<remote command>…]
  1. Fetches the machine’s jump host, user and host keys from the portal. If the portal has no host key yet (the machine is still being created), it stops with exit code 1.
  2. Replaces the machine’s lines in ~/.config/agentspaces/known_hosts with the portal’s.
  3. Picks the key to offer: a registered key from your SSH agent, else a registered default key in ~/.ssh (see Connect over SSH). Skipped when you pass -i.
  4. Runs ssh -J <jump host> -o UserKnownHostsFile=~/.config/agentspaces/known_hosts -o StrictHostKeyChecking=yes -o HostKeyAlias=<machine id> root@<machine id> [arguments]. With a key from step 3 it adds -o IdentitiesOnly=yes -i <key>, and reaches the jump host with a ProxyCommand instead of -J, so the jump host is offered the same single key.

Add -v before ssh to see the requests and the exact command: space -v ssh dev.

A member reaches no machine over SSH: space ssh and space ssh-config say so (exit code 3) before ssh runs.

Everything after <machine> is passed to ssh after the destination: options first, then the remote command (space ssh dev -L 8080:localhost:80, space ssh dev uptime).

If the first thing after the machine name is one of space’s own global flags (-v, -q, -o, --json, …), space takes it itself: space ssh dev -o ServerAliveInterval=30 sets the organization, not an ssh option. Put -- after the machine name to hand everything to ssh:

space ssh dev -- -v
space ssh dev -- -o ServerAliveInterval=30

ssh is taken from PATH, or from AGENTSPACES_SSH. The exit status is ssh’s, which is the remote command’s when you run one.

space ssh-config

space ssh-config [--write]

Prints a Host <machine>.<org> block for every machine in the organization (HostName, User, ProxyJump, UserKnownHostsFile, StrictHostKeyChecking, HostKeyAlias), and refreshes their host keys in ~/.config/agentspaces/known_hosts. Machines whose SSH details cannot be fetched are skipped with a message on stderr. Unlike space ssh, the blocks do not pin a key: ssh offers your keys as usual. --write writes the blocks to ~/.config/agentspaces/ssh_config instead and prints the Include line to add at the top of ~/.ssh/config, before any Host block.

Last updated on