Skip to content

Connecting

Connect over SSH through Legion's gateway, save an SSH config, copy files and use the web terminal.

On this page

You reach every rental through Legion's SSH gateway, by the rental's name. The gateway only relays: your SSH session runs end to end between your computer and the rental. You log in as root, with the key you chose when you rented, or the one you changed it to. See Change or revoke the key of a rental.

The commands below use the rental name quiet-river-7k2f and the key ~/.ssh/id_ed25519. The rental's page builds them for you with its own name and the key path you enter.

The quickest way

Add your key to the SSH agent, then jump through the gateway:

Shell
ssh-add ~/.ssh/id_ed25519
ssh -J ssh.legion.ambient.xyz:22 -o HostKeyAlias=quiet-river-7k2f root@quiet-river-7k2f

The agent offers your key to both hops, the gateway and then your rental, so you name it once. HostKeyAlias stores the rental's host key under its own name.

Save it in your SSH config

Add this to ~/.ssh/config:

Text
Host quiet-river-7k2f-gateway
  HostName ssh.legion.ambient.xyz
  Port 22
  User legion
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

Host quiet-river-7k2f
  HostName quiet-river-7k2f
  User root
  HostKeyAlias quiet-river-7k2f
  ProxyJump quiet-river-7k2f-gateway
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes
  ServerAliveInterval 60

Then connect any time with:

Shell
ssh quiet-river-7k2f

Use ~/ or a full path for the key. A relative path is read from the folder you run ssh in.

From the command line

With the legion CLI, legion ssh quiet-river-7k2f connects in one step. legion rental ssh-config quiet-river-7k2f prints the config block above for you.

Copy files and forward ports

With the config saved, tools that use SSH work with the rental's name. SFTP and TCP forwarding are on.

Shell
scp ./data.tar.gz quiet-river-7k2f:/workspace/
rsync -avz ./project/ quiet-river-7k2f:/workspace/project/

To reach a service in the rental privately, forward its port with ssh -L. Editors that work over SSH can open /workspace through the same name.

One command, without the agent

If you don't use an SSH agent, the rental's page has a one-line command under One command, without the agent. It names your key twice, because the gateway checks your key too.

Agent forwarding

ssh -A forwards your keys only if you ticked Allow SSH agent forwarding when you rented. You can't change it afterwards. While your agent is forwarded, anyone with root in the rental can use your keys wherever they work.

After you change the key

When you change a rental's key, the rental keeps running. The gateway accepts only the new key within about 30 seconds, and sessions that used the old key close within about a minute. Point ssh-add and IdentityFile at the new private key, then connect again. The host key doesn't change, so you won't see a host key warning.

Gateway limits

The gateway accepts a limited number of new connections per minute from one IP address. It closes a connection after 30 minutes with no traffic. ServerAliveInterval 60 in the config above keeps an idle session open.

The web terminal

The web terminal opens a root shell in your browser, from the rental's page.

  • It's on unless you turned off Allow the web terminal when you rented. You can't change it afterwards.

  • You choose who can open it when you rent, next to Allow the web terminal:

    • Everyone in your organization (the default): any owner or member who can manage rentals.

    • Only you and the owners: the person who created the rental and your organization's owners. Other members see Open terminal turned off, with the reason.

  • The person who created the rental, or an owner, can change who can open it on the rental's page. A person who loses access is disconnected within a minute. A rental created before this choice existed is open to everyone in the organization, and only an owner can change that.

  • You confirm your identity before opening it; that lasts 15 minutes.

  • Each session uses a certificate that expires after 120 seconds. The terminal closes after 30 minutes without input.

  • It needs a browser with WebGL 2.

  • Every session is listed on the rental's page.

Can't connect?

  • Permission denied (publickey): check that the key path is the private key matching the public key you rented with. Run the ssh-add line again, or use the config with IdentityFile.

  • ssh-add asked for a passphrase and nothing else happened: run the ssh line again once ssh-add is done.

  • It just turned Running: try again in a moment.

  • Host offline: your rental resumes when the host is back. Connect again then.