# Create an SSH key

An SSH key lets you log in to your GPU securely without a password. It has two halves: a **private key** that never leaves your computer, and a **public key** that you give to us. Add the public key once and every GPU you rent accepts it.

If you already have a key, you don't need a new one: skip to [Find your public key](#find-your-public-key).

## macOS and Linux

1. Open **Terminal**.
2. Run:

   ```bash
   ssh-keygen -t ed25519 -C "my-laptop"
   ```

3. Press Enter to save it in the default place, `~/.ssh/id_ed25519`. If it asks to overwrite an existing key, answer `n`: you already have one.
4. Type a passphrase to protect the key (recommended), or press Enter twice for none.

## Windows

Windows 10 and 11 include SSH.

1. Open **PowerShell** (press Start and type "PowerShell").
2. Run:

   ```powershell
   ssh-keygen -t ed25519 -C "my-laptop"
   ```

3. Press Enter to save it in the default place, `C:\Users\<you>\.ssh\id_ed25519`.
4. Type a passphrase (recommended), or press Enter twice for none.

If PowerShell says `ssh-keygen` isn't recognised, add it under **Settings → System → Optional features → OpenSSH Client**, then try again.

## Find your public key

The public key is the file ending in **`.pub`**, next to the private key. Print it with:

| System | Command |
|---|---|
| macOS, Linux | `cat ~/.ssh/id_ed25519.pub` |
| Windows (PowerShell) | `Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub` |

It is one line that starts with `ssh-ed25519` (or `ssh-rsa` for an older key), for example `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA… my-laptop`. Copy the whole line.

> **Paste the public key only.** Never paste or share your private key: the file with no `.pub` ending, which starts `-----BEGIN OPENSSH PRIVATE KEY-----`. Anyone who has it can log in as you.

## Add it to Green Compute

On the [GPU Rental](https://www.green-compute.com/rental) page, in the **SSH Keys** box, give the key a name you'll recognise, paste the line into **Public key** and choose **Add Key**. Over the API, put it in `metadata.ssh_public_keys` when you create a workload (see the [GPU rental reference](https://www.green-compute.com/docs/gpu-rental.md)).

A key applies to GPUs you rent after adding it. A pod that is already running keeps the keys it started with.

## Connect

When your rental is ready, **My Rentals** shows the exact command, for example:

```bash
ssh root@203.0.113.7 -p 40123
```

If your key isn't in the default place, add `-i` and its path: `ssh -i ~/keys/work_key root@203.0.113.7 -p 40123`.
