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

# Connect to a Computer with SSH

> Authorize a public key, get the current endpoint, and use a standard SSH client with your Deepest Computer.

Deepest Computers accept standard SSH connections for interactive shells, remote commands, SFTP, and local TCP forwarding. SSH keys are authorized for one Computer. The platform never needs your SSH private key.

Use SSH when you want your own terminal or standard development tools. For a single programmatic command, the [Exec API](https://docs.deepest.dev/connect/commands.md) may be simpler. SSH, Desktop, and Exec operate on the same Computer and disk.

## Before connecting

You need a Computer you own, a current entitlement that permits running it, a Running state, a local OpenSSH client, and a key pair. SSH does not create or start a Computer for you.

Run these commands on your **local computer**:

```bash theme={null}
ssh -V
ssh-keygen -t ed25519 -f "$HOME/.ssh/deepest_ed25519" -C "deepest-laptop"
```

Choose a passphrase when prompted. If that file already exists, use your existing key or choose another filename; do not overwrite a key you still need. The file ending in `.pub` is public. The file without that suffix is private and stays on your local computer.

View the public key:

```bash theme={null}
cat "$HOME/.ssh/deepest_ed25519.pub"
```

It should be a single line starting with `ssh-ed25519`. Never paste a file beginning with a private-key header.

## Authorize the public key

In the Console, select your Computer and open **Connect → Add public key**. Enter the complete public-key line in **Public key**, optionally fill in **Label (optional)**, and choose **Save key**.

The **SSH public keys** list shows each authorized key's fingerprint and offers **Remove** to revoke it.

For an Agent or integration, the equivalent operation is:

```js theme={null}
import { readFile } from "node:fs/promises";
import { Deepest } from "@deepest/sdk";

const { DEEPEST_API_URL, DEEPEST_API_KEY, COMPUTER_ID, SSH_PUBLIC_KEY_FILE } = process.env;
if (!DEEPEST_API_URL || !DEEPEST_API_KEY || !COMPUTER_ID || !SSH_PUBLIC_KEY_FILE) {
  throw new Error("Set the control API URL, Agent Key, Computer ID, and public-key file path.");
}
const deepest = new Deepest({ baseUrl: DEEPEST_API_URL, apiKey: DEEPEST_API_KEY });
const computer = deepest.computer(COMPUTER_ID);
const reply = await computer.ssh.keys.add({
  public_key: (await readFile(SSH_PUBLIC_KEY_FILE, "utf8")).trim(),
  label: "development laptop",
});
if (!reply.ok) {
  console.error(reply.error.code, reply.retry, reply.resource_id);
  process.exit(1);
}
console.log(reply.result.fingerprint);
```

Install the SDK from npm as described in [TypeScript SDK](https://docs.deepest.dev/api-and-sdk/typescript.md). This example runs in your trusted local process; do not copy the Account Agent Key into the Computer.

Adding the same public key again returns its existing authorization. Changing the label is not a way to create another grant. A key authorized on Computer A does not automatically authorize Computer B.

## Obtain the endpoint

In the same **Connect** tab, choose **Get SSH command**. Use **Copy** under **Run in your local shell** to copy the displayed command.

The SDK equivalent, using the client above, is:

```js theme={null}
const endpointReply = await computer.ssh.endpoint();
if (!endpointReply.ok) {
  console.error(endpointReply.error.code, endpointReply.retry, endpointReply.resource_id);
  process.exit(1);
}
console.log(endpointReply.result); // { host, port, user }
```

Use all three returned values. The endpoint's port is not necessarily 22. Do not substitute a public IP observed from inside the Computer: an outbound address is not an SSH endpoint.

```bash theme={null}
ssh -i "$HOME/.ssh/deepest_ed25519" -o IdentitiesOnly=yes \
  -p <SSH_PORT> <SSH_USER>@<SSH_HOST>
```

Replace `<SSH_HOST>`, `<SSH_PORT>`, and `<SSH_USER>` with the endpoint response. `-i` selects your local private key. `IdentitiesOnly=yes` prevents unrelated keys in your agent from being tried.

### Understand the first host-key prompt

Your SSH public key proves your identity to the Computer. The server's host key helps your SSH client recognize the Computer. They are different keys.

OpenSSH may ask you to trust the server on first connection. Obtain the endpoint through your authenticated Console or API; compare the fingerprint with a separately trusted value when one is available. The current endpoint response contains host, port, and user, but does not supply an independently authenticated host-key fingerprint. Treat first-use acceptance as first-use trust, not cryptographic verification provided by Deepest.

> [!WARNING]
>
> Do not disable host-key checking to silence a mismatch. A normal Stop/Start of the same Computer preserves its host key. A Clone is a new Computer with a new host key.

## Confirm where you are

After connecting, run:

```bash theme={null}
uname -s
id
pwd
printf 'Connected to the cloud Computer\n'
```

Expect `Linux`, the remote user identity, a Guest directory, and the message. Your local prompt returns when you run `exit`.

For a remote command without an interactive session:

```bash theme={null}
ssh -i "$HOME/.ssh/deepest_ed25519" -o IdentitiesOnly=yes \
  -p <SSH_PORT> <SSH_USER>@<SSH_HOST> 'uname -s; git --version'
```

A successful SSH connection does not make every application command successful. Inspect the command's exit status and output separately. If a connection drops after you sent a command, inspect its effects before running a mutating command again.

## Keep a convenient SSH configuration

Add an entry to your local `~/.ssh/config` after replacing the placeholders:

```sshconfig theme={null}
Host deepest-work
  HostName <SSH_HOST>
  Port <SSH_PORT>
  User <SSH_USER>
  IdentityFile ~/.ssh/deepest_ed25519
  IdentitiesOnly yes
  HostKeyAlias deepest-<COMPUTER_ID>
```

Then connect with `ssh deepest-work`. The alias is your local convenience; it creates no Deepest object. `HostKeyAlias` lets your client associate the host key with the stable Computer ID rather than a replaceable endpoint. Use a different alias for each Computer and confirm first-use trust when introducing it.

Fetch the current endpoint again after a refused connection or platform reconnect. Endpoint host/port values are connection details and can change. Updating them in this entry does not change the Computer's identity or disk.

## Stop, reconnect, and revoke

| Action | Effect |
| - | - |
| Exit SSH | Ends that shell; does not Stop the Computer |
| Close your local terminal | Does not guarantee that every launched remote process stops |
| Stop Computer | Stops computing and disconnects access; the disk remains |
| Start the same Computer | Cold-boots its retained disk; fetch the current endpoint and reconnect |
| Revoke a key | Prevents new connections using that authorization; existing connections are not guaranteed to be terminated |
| Clone Computer | Creates a separate identity and host key; Deepest SSH grants are not copied |
| Restore a disk snapshot | Retains the original Computer's current SSH grants and host identity |

To revoke with the SDK:

```js theme={null}
const keys = await computer.ssh.keys.list();
if (!keys.ok) throw new Error(keys.error.code);
console.log(keys.result.map(({ fingerprint, label }) => ({ fingerprint, label })));

// Set this from the exact key you intend to revoke.
const fingerprint = process.env.SSH_KEY_FINGERPRINT;
if (!fingerprint) throw new Error("Set SSH_KEY_FINGERPRINT.");
const removed = await computer.ssh.keys.remove(fingerprint);
if (!removed.ok) throw new Error(removed.error.code + " / " + removed.retry);
```

After revocation, test a **new** connection if you need to verify the effect. Revocation does not delete local private keys or third-party credentials inside the Guest. If the result is `UNKNOWN`, list the Computer's keys before another change.

## Respond to an exposed private key

Treat an exposed private key as a credential that needs replacement, not as a problem solved by renaming its label.

1. Work from a trusted local device and your authenticated Console or control client. Generate a new key pair with a new filename; keep the new private key on that local device.
2. Authorize only the new public key on each Computer that still needs this client's access. Test a new connection using that new key and the current endpoint.
3. List the affected Computers' authorized keys and revoke the old key's exact fingerprint on every Computer where it was granted. A grant is per Computer; replacing it on one does not revoke it elsewhere.
4. Check a fresh connection using the old key and confirm that new access is refused. Existing SSH shells, SFTP sessions and tunnels may still be alive: if containment requires ending them, identify and terminate the affected Guest sessions, or explicitly Stop the Computer after considering its running work.
5. Inspect any Computer that may have been accessed. Review affected files and third-party credentials, rotate exposed provider credentials through their own service, and preserve needed evidence. A replacement SSH key does not remove files an intruder may have changed or clear an already established third-party session.

If unauthorized access may be continuing, revoke the old authorization first instead of waiting for the replacement connection test. The trusted Console/control path can authorize your replacement afterward. Do not disable host-key checking or place the Account Agent Key inside the Guest as a workaround.

## Troubleshoot the symptom

| Symptom | What to check | Recovery |
| - | - | - |
| `NOT_RUNNING` | Current Computer state | Explicitly Start it if appropriate, then fetch the endpoint |
| `ENTITLEMENT_REQUIRED` | Account eligibility | Restore valid access; repeated SSH requests do not restore entitlement |
| `Permission denied (publickey)` | Correct Computer, private key, public-key grant, user | Compare the public key's fingerprint with the grant; select the matching private key |
| Connection refused or timeout | Current endpoint and network reachability | Refresh endpoint; check your local firewall/network; preserve the Computer |
| Host-key changed warning | Computer ID, endpoint, recent Clone or support action | Stop and investigate; do not blindly remove `known_hosts` entries |
| `NOT_FOUND` from API | ID and current Account | Select a Computer belonging to this Account |
| Shell works but app fails | Guest dependencies, disk, RAM and application logs | Diagnose in the Guest; SSH success does not establish application readiness |

SSH processes and the applications they launch use the Computer's memory, the Account's shared CPU, and its storage. See [Account resources](https://docs.deepest.dev/concepts/account-resources.md). Stop work you no longer need; closing the SSH client alone is not a resource-release operation.

## Continue

Use [SFTP](https://docs.deepest.dev/connect/sftp.md) to move files, [local port forwarding](https://docs.deepest.dev/connect/port-forwarding.md) for a private tunnel, or [VS Code Remote SSH](https://docs.deepest.dev/connect/vscode.md) for an IDE workflow. Precise request/response schemas live in the [API reference](https://docs.deepest.dev/api-reference.md), under SSH.

Standard client behavior is documented in the official [OpenSSH client manual](https://man.openbsd.org/ssh.1) and [client configuration manual](https://man.openbsd.org/ssh_config.5).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.