# Rent a GPU and SSH in

> Sign in, add credit, rent a GPU from the market and connect to it over SSH.

Source: https://legion.ambient.xyz/docs/get-started/rent-a-gpu

In this guide you rent one GPU, connect to it as root over SSH, and stop it when you're done. It takes about five minutes, plus the time the host needs to download your image.

**You need:**

- An account at [legion.ambient.xyz](https://legion.ambient.xyz). Legion is in closed beta: you need an invitation, or approval from the waitlist.
- An SSH key pair on your computer. To make one, run `ssh-keygen -t ed25519`.
- Credit in your organization, or an owner who can add it.

## Step 1: Sign in

Go to [legion.ambient.xyz](https://legion.ambient.xyz) and sign in. If your account isn't approved, you see **Join the waitlist**. Join it, and confirm with the link in the email.

## Step 2: Accept the Terms

Read and accept the Terms of Use and the Acceptable Use Policy, and acknowledge the Privacy Policy and Data Handling. You'll be asked again when a new version comes out.

## Step 3: Set up your account

Onboarding walks you through a few short steps:

1. Accept your invitation, or name your own organization.
2. Check your name.
3. Choose what you'll do. Pick **Rent**.
4. Add your SSH public key: paste one line from your `.pub` file, for example `~/.ssh/id_ed25519.pub`.

## Step 4: Add credit

Rentals are paid from your organization's prepaid balance.

- **If you're an owner:** open **Spend** and press **Add credit**. You pay by card, US bank debit or USDC through Stripe Checkout. Card and USDC credit arrives once you pay. A bank debit can take up to 4 business days to arrive.
- **If you're a member:** press **Ask an owner** and send the details to an owner of your organization.

## Step 5: Pick an offer

Open **Market**. Each offer is one host: its GPU model, memory per GPU, CUDA version, driver, GPUs free, price per GPU-hour, Legion score and 30-day uptime. Filter and sort until you find one you like, then press **Rent**.

## Step 6: Rent it

On the rent form:

1. Choose how many GPUs.
2. Choose what to run: a starter image, a model Legion serves for you, or your own image. The newest starter image the host can run is chosen for you. See [Images and the runtime](https://legion.ambient.xyz/docs/renting/images).
3. Choose your SSH key. None is chosen for you, because the key you pick gets root on the rental.
4. Check the receipt: price per GPU-hour, the hourly total, your balance and your runway.
5. Press **Rent 1 GPU for …/hr**.

For an interruptible rental, you also set your max price. See [How the auction works](https://legion.ambient.xyz/docs/renting/interruptible-rentals#how-the-auction-works).

## Step 7: Wait for Running

The rental shows **Starting** while the host downloads and starts your image. You aren't billed while it starts. Large images can take several minutes. If it can't start within 10 minutes, it fails and you aren't billed.

When it shows **Running**, billing starts.

## Step 8: Connect

In the rental's **Connect** section, enter the path to your private key, for example `~/.ssh/id_ed25519`. Press **Copy SSH commands** and paste them into a terminal. They look like this:

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

`quiet-river-7k2f` is the rental's name. Yours is different.

You're now root in your rental. Check the GPUs:

```sh
nvidia-smi
```

Keep your work in `/workspace`. On starter images it stays while the rental runs. Once the rental stops, its files stay on the host for at least 24 hours and at most 72 hours, then are deleted. To keep them longer, make a [backup](https://legion.ambient.xyz/docs/renting/stopping-and-backups#backups). An [interruptible rental](https://legion.ambient.xyz/docs/renting/interruptible-rentals) set to delete on preemption loses its workspace when it's preempted.

## Step 9: Stop or delete it

When you're done, open the rental and choose one:

- **Stop rental** ends GPU billing and gives the GPUs back to the market. Your files stay on the host for at least 24 hours and at most 72 hours, and storage is billed while they're there. You can start it again in that time if the host's GPUs and disk are free. **Back up and stop** keeps a copy for 7 or 30 days.
- **Delete rental** removes the container and its files for good. Billing stops. **Back up, then delete** keeps a copy first.

See [Stopping, backups and how long your data is kept](https://legion.ambient.xyz/docs/renting/stopping-and-backups).

## Prefer the terminal?

You can do all of this with the `legion` command line. See [The legion command line](https://legion.ambient.xyz/docs/cli).

## Next steps

- [Connecting](https://legion.ambient.xyz/docs/renting/connecting): save an SSH config, copy files and forward ports.
- [Rental lifecycle](https://legion.ambient.xyz/docs/renting/rental-lifecycle): every state, and what each one costs.
- [Credit and billing](https://legion.ambient.xyz/docs/renting/credit-and-billing): how charges are worked out.
