Skip to main content
Connect over SSH to a running training job that has SSH enabled, and get a shell in its container. Use it to debug, inspect files, run commands, and copy files with scp or sftp. SSH is terminal-first and works with any OpenSSH-compatible tool. To attach an IDE instead, see Connect with remote tunnels.

Prerequisites

  • Training Jobs enabled for your organization. See Request access.
  • SSH set up on your machine. See Set up SSH.
  • uv on your PATH. The Baseten CLI runs Truss through uv to push jobs and create workstations.

Enable SSH on a training job

To enable SSH access on a training job, set session_provider to SSH in your config.py:
config.py
This example sets trigger=ON_STARTUP so the session is available as soon as the job starts running. The default is ON_DEMAND, which activates the session on your first SSH connection; see Trigger modes for all options. Training jobs support H200 and H100 GPUs. For all InteractiveSession fields, see the SDK reference. For supported compute, see Compute resources.

Push an SSH-enabled training job

This walkthrough pushes the MNIST PyTorch example with SSH enabled, then connects to its container from your terminal.
The job bills for its GPUs while it runs. With ON_STARTUP, the container keeps running after the training script exits, until you stop the job or the session expires. The last step stops the job.
To push an SSH-enabled job and connect:
  1. Clone the cookbook and change into the MNIST training example:
    Terminal
  2. Edit config.py to add an interactive_session with session_provider=SSH, as shown in Enable SSH on a training job.
  3. Push the job:
    Copy <job_id> from the output. The Baseten CLI runs Truss to push the job, so the hints name Truss commands. Use the Baseten CLI commands on this page instead.
  4. Check that the job is running. Its Status: line reads running:
  5. Connect to node 0:
    Terminal
    You’re connected when you see a shell prompt like root@baseten-training-job-<job_id>-multinode-0:~#. Baseten extracts your source files to /b10/workspace (available as $BT_WORKING_DIR). If you set enable_baseten_workdir=False, Baseten uses your base image’s WORKDIR instead.
  6. When you finish, stop the job so it stops billing, and confirm when prompted:

Hostname format

Training hostnames name a job and a node:
Hostname
Examples:
Terminal

Multi-node jobs

For multi-node training jobs, specify the node index in the hostname. Node 0 is the leader:
Terminal

File transfer

Use scp or sftp with the same hostname to transfer files. Each command returns to your prompt when the transfer finishes:
Terminal

Open the container in VS Code or Cursor

Because setup configures standard OpenSSH, tools that speak SSH can connect with the same hostname:
  • VS Code: Install the Remote - SSH extension, then connect to training-job-<job_id>-<node>.ssh.baseten.co.
  • Cursor: Use the built-in SSH remote feature with training-job-<job_id>-<node>.ssh.baseten.co.

Session expiry

An SSH session’s expiry doesn’t change after the session starts, and reconnecting doesn’t extend it. See Session expiry to choose the length before you push the job and to see which files survive the session.

Troubleshoot connections

”Invalid job id: must be a valid hash id”

Check that the job ID in the hostname is correct. Find your job ID with baseten train job list or in the Baseten dashboard.

Training job not found or unreachable

SSH requires a running training job. For a stopped or finished job, ssh prints training job "<job_id>" not found and then fails to resolve the hostname. Check that the job’s Status: line reads running:
If the job is running but SSH still fails, the job may not have SSH enabled. Confirm that your config sets session_provider=InteractiveSessionProvider.SSH, as shown in Enable SSH on a training job.

Next steps