SSH
Open shells, run commands, copy files and forward ports over SSH through the pols gateway.
Every running sandbox is reachable over SSH through the gateway at ssh.pols.so. Register your public key once, and it opens every running sandbox of your org.
pols ssh-key add ~/.ssh/id_ed25519.pub
pols ssh web # an interactive shell
pols ssh web -- uname -a # one command
pols ssh web --print # the plain ssh command, to use with scp, sftp or your own options
pols ssh takes the sandbox the way you see it: its ID, its name, its host label, or the host of its desktop or a port, such as braveotterk3f9, braveotterk3f9-desktop or braveotterk3f9-desktop.on.pols.so. It looks the sandbox up first, so a sandbox that is not in your current org fails before any ssh runs. If it is in another of your orgs, the error says which one: switch with pols org use ORG.
Keys
pols ssh-key add ~/.ssh/id_ed25519.pub # register a key (the comment becomes its label)
pols ssh-key ls # registered keys with their IDs and fingerprints
pols ssh-key rm KEY # remove one; its open sessions end within 10 seconds
Keys belong to the org, not to a sandbox: any registered key opens every running sandbox of the org, including sandboxes created later. Register a colleague’s key to let them in, and remove it to let them out. Over the API, keys are managed at /v1/ssh-keys.
An SSH key depends on the API key that registered it: revoking that API key deletes the SSH keys it registered, and once it expires they stop working (registering such a key again moves it to the new API key). Removing a user from the org deletes their SSH keys. The gateway re-checks open sessions, so a session ends within 10 seconds of its key no longer being accepted: the key removed, its API key revoked or expired, its user removed, the org disabled or the sandbox deleted.
An SSH key registered with an API key that is limited to some sandboxes opens only that API key’s sandboxes, and stops opening any once all of its sandboxes are deleted. With such an API key, pols ssh-key ls shows and pols ssh-key rm removes only the SSH keys it registered.
How the gateway works
The gateway routes by user name: you connect as <sandbox ID>@ssh.pols.so, and it checks your key with the control plane, then logs into the sandbox’s SSH server as user with a certificate that is valid for two minutes. Shells, commands, scp, sftp, agent forwarding and port forwarding are relayed.
The gateway listens on the standard SSH port 22, so plain ssh sbx_...@ssh.pols.so reaches it. pols ssh and pols ssh --print use the port the API names, as does GET /v1/sandboxes/{sandbox}/ssh, which returns the host, port, user and the full command.
$ pols ssh web --print
ssh sbx_...@ssh.pols.so
Use the printed command with standard tools:
scp ./data.csv sbx_...@ssh.pols.so:/home/user/
ssh -L 5432:localhost:5432 sbx_...@ssh.pols.so # reach the sandbox's Postgres on your machine
Port 2222 reaches the gateway as well, so older commands such as ssh -p 2222 sbx_...@ssh.pols.so and a Port 2222 entry for ssh.pols.so in ~/.ssh/config keep working. If you have such an entry, you can remove it.
The gateway only accepts keys registered with pols ssh-key add; keys you add to ~/.ssh/authorized_keys inside the sandbox do not open it from outside, because the sandbox’s own SSH server is not reachable from the internet. Password logins are off.
When it does not connect
- Connect to port 22 or 2222 of
ssh.pols.so. If a network blocks outgoing SSH on port 22, usessh -p 2222. - The sandbox must be running. Resume a stopped one with
pols resume. - Your key must be registered: check
pols ssh-key lsand compare the fingerprint withssh-keygen -lf ~/.ssh/id_ed25519.pub. - Use the sandbox ID, not its name or host label, as the SSH user name.
pols sshresolves those for you. - The sandbox must be in the org your key is registered with.
pols sshtells you when it is in another of your orgs.