> ## Documentation Index
> Fetch the complete documentation index at: https://runcrate.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting to Instances

> Connect via SSH, VS Code, and port forwarding.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Once your instance is **Deployed**, you can connect via SSH, set up VS Code Remote, and forward ports for services like Jupyter.

## SSH Connection

The SSH command is available on your instance's detail page. The general format is:

```bash theme={"theme":"github-dark"}
ssh root@<instance-ip> -p <port> -i ~/.ssh/your_key
```

For example:

```bash theme={"theme":"github-dark"}
ssh root@203.0.113.42 -p 22 -i ~/.ssh/id_rsa
```

<Note>
  Some instances use a non-standard SSH port. Always check the port shown in your instance details.
</Note>

### First Connection

On your first connection, you will be asked to confirm the server fingerprint:

```
The authenticity of host '203.0.113.42 (203.0.113.42)' can't be established.
ED25519 key fingerprint is SHA256:xxxxx.
Are you sure you want to continue connecting (yes/no)?
```

Type `yes` to continue. This is normal for new instances.

## Verify GPU Access

After connecting, confirm that your GPU is available:

```bash theme={"theme":"github-dark"}
# Check GPU status
nvidia-smi

# Check CUDA version
nvcc --version

# Verify PyTorch GPU access (if Finetune or Inference template)
python3 -c "import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0))"
```

## Port Forwarding

To access services running on your instance from your local browser, use SSH port forwarding:

```bash theme={"theme":"github-dark"}
ssh root@<instance-ip> -p <port> -i ~/.ssh/your_key -L <local-port>:localhost:<remote-port>
```

### Common Ports

| Service          | Remote Port | Local Forward Command    |
| ---------------- | ----------- | ------------------------ |
| Jupyter Notebook | 8888        | `-L 8888:localhost:8888` |
| TensorBoard      | 6006        | `-L 6006:localhost:6006` |
| Gradio           | 7860        | `-L 7860:localhost:7860` |
| VS Code Server   | 8080        | `-L 8080:localhost:8080` |

**Example** -- forward Jupyter to your local machine:

```bash theme={"theme":"github-dark"}
ssh root@203.0.113.42 -p 22 -i ~/.ssh/id_rsa -L 8888:localhost:8888
```

Then open `http://localhost:8888` in your browser.

## VS Code Remote SSH

VS Code can connect directly to your instance for a full IDE experience.

### Setup Steps

1. Install the **Remote - SSH** extension in VS Code.
2. Open the Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`).
3. Select **Remote-SSH: Connect to Host...**.
4. Enter the connection string: `root@<instance-ip> -p <port>`.
5. When prompted, select the SSH key to use.
6. VS Code will install its server component on the instance and connect.

### SSH Config (Optional)

For quicker access, add your instance to `~/.ssh/config`:

```
Host runcrate-instance
    HostName 203.0.113.42
    Port 22
    User root
    IdentityFile ~/.ssh/id_rsa
```

Then connect with: `ssh runcrate-instance` or select `runcrate-instance` from VS Code.

## File Transfer

Use `scp` to copy files to and from your instance:

```bash theme={"theme":"github-dark"}
# Upload a file
scp -P <port> -i ~/.ssh/your_key ./local-file.py root@<instance-ip>:/root/

# Download a file
scp -P <port> -i ~/.ssh/your_key root@<instance-ip>:/root/results.csv ./

# Upload a directory
scp -r -P <port> -i ~/.ssh/your_key ./my-project root@<instance-ip>:/root/
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Connection refused">
    * Verify the instance status is **Deployed** on the dashboard.
    * Confirm you are using the correct IP address and port from the instance details.
    * The instance may still be starting up -- wait a minute and try again.
  </Accordion>

  <Accordion title="Permission denied (publickey)">
    * Ensure your SSH key is added to your Runcrate account and was selected during deployment.
    * Verify you are using the correct key file: `ssh -i ~/.ssh/correct_key ...`
    * Check file permissions: `chmod 600 ~/.ssh/your_key`
  </Accordion>

  <Accordion title="Connection timed out">
    * Check your local network and firewall settings.
    * Verify the instance IP and port on the dashboard.
    * If the instance was recently deployed, wait 1-2 minutes for networking to initialize.
  </Accordion>
</AccordionGroup>
