What is the Databricks SSH tunnel and when should I use it?
Summary
- The Databricks SSH tunnel connects Visual Studio Code, Cursor or a terminal on your machine to Databricks serverless compute, AI Runtime or a dedicated classic cluster. Your Python environment and code execution run on the remote compute.
- It's in Beta. You start it from your local machine with the Databricks CLI (
databricks ssh connect), and it can't be launched from another remote environment or a Docker container. - Use it for IDE-driven development: editing workspace files and running or debugging Python scripts and notebooks in the same environment your cluster or serverless workloads use.
- Pick Databricks Connect when only your Spark API code needs to run remotely, the Databricks Sandbox (Beta) for running coding agents in a sandboxed environment, and jobs or bundles for long-running work.
What is the Databricks SSH tunnel and when should I use it?
The Databricks SSH tunnel is a Beta feature of the Databricks CLI that connects your local editor or terminal to Databricks compute over SSH. Use it when you want to keep your own IDE but run code where your workspace files, libraries and data access already live. It moves the whole development environment onto the compute: Python, the kernel and code execution all run on Databricks, not on your laptop. For long-running or scheduled work, the docs point you to jobs or bundles.
What is the Databricks SSH tunnel?
The docs describe a tunnel that "connects Visual Studio Code, Cursor, or your terminal to the Databricks workspace and Databricks serverless compute, AI Runtime, or classic compute." You can connect directly to serverless compute, or set up a reusable SSH host entry for a dedicated classic cluster.
A few technical facts shape how it behaves:
- Transport. It doesn't use port 22. Traffic goes over HTTPS to your workspace domain and needs WebSocket support, so your network, VPN, firewall and proxy must allow it.
- Identity. Authentication uses the Databricks CLI and your configured workspace profile, and the session is authenticated as the user who starts it. SSH traffic is encrypted end-to-end.
- Requirements. Databricks CLI version 1.5.0 or above on your local machine, plus Visual Studio Code with the Remote - SSH extension, or Cursor. Those two IDEs are officially supported; other IDEs with SSH capabilities are compatible but untested.
When to use it, and when to pick something else
| If you want to… | Use | Why |
|---|---|---|
| Edit workspace files and run or debug Python and notebooks from your IDE on Databricks compute | SSH tunnel (Beta) | Code runs in the same environment as your cluster or serverless compute |
| Write Spark API code locally and run it on Databricks compute | Databricks Connect | Runs Spark code remotely from any IDE, notebook server or custom application |
| Define, deploy and run Declarative Automation Bundles from your IDE | Databricks IDE extension | Connects Visual Studio Code or Cursor to a workspace with a few clicks |
| Run agent loops or execute untrusted code | Databricks Sandbox (Beta) | Lightweight, isolated serverless compute built for that purpose |
| Run long or multi-node GPU training | databricks air on AI Runtime, or a job |
An SSH session on AI Runtime is interactive and single-node |
Two cautions from the docs: the SSH tunnel and the Databricks IDE extension "are not compatible and should not be used together," and shared clusters aren't supported.
Key questions to ask before you adopt it
- Which compute do you need? Serverless needs no setup step. GPUs come through AI Runtime with the
--acceleratorflag. Classic compute must be a dedicated, single-user cluster on Databricks Runtime 17.0 or above with Unity Catalog enabled. - Has your admin enabled it? Serverless connections need port forwarding to serverless compute. It's on by default, except in workspaces with the compliance security profile.
- Where will your files live? Files in
/Workspace,/Volumesand/dbfspersist across cluster restarts. Files in/home,/rootand other local paths are lost on restart. - How will you manage dependencies? Use workspace base environments for serverless, cluster libraries for classic compute, or a
%pipsetup notebook for project-scoped packages.
How Databricks approaches remote IDE development
The tunnel ships as the ssh command group in the Databricks CLI. For serverless compute, run:
databricks ssh connect --ide vscode
Swap in --ide cursor, or omit --ide for an interactive terminal session. For a dedicated cluster, run databricks ssh setup --name <connection-name> once. The CLI adds a host entry to your SSH configuration, and you connect with ssh <connection-name> or from your IDE's Remote-SSH menu.
The session opens to an ephemeral directory, so navigate to /Workspace/Users/<your-username> to work on workspace files. Select the pythonEnv-xxx interpreter the session provides; on classic compute it includes the built-in Databricks Runtime libraries and compute-scoped libraries. Notebooks (.ipynb) get Databricks globals such as spark, dbutils and display, while plain Python files must import them explicitly.
By default the tunnel shuts down 10 minutes after the last client disconnects, and it stops the processes the session started. The --shutdown-delay and --keep-detached-processes flags change that behavior, but the compute keeps running, and incurring cost, while the tunnel stays up.
For setup details, see Connect to Databricks using an SSH tunnel and the IDE tools comparison.
FAQs
Is the Databricks SSH tunnel generally available?
No. It's in Beta, and the docs note that cost and pricing for features in Beta are subject to change.
How is the SSH tunnel different from Databricks Connect?
Databricks Connect runs your Spark API code on Databricks compute while the rest of your environment stays local. The SSH tunnel moves the entire development environment, including Python and the kernel, onto the compute.
Does the SSH tunnel need port 22 open?
No. It carries traffic over HTTPS to your workspace domain, and your network, proxy and firewall must allow WebSocket upgrades to that domain.
Can I start the tunnel from a container or a remote VM?
No. Start the connection from your local machine. The docs say the tunnel can't be launched from another remote environment or a Docker container.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.