Coding agents like Claude Code and Cursor connect to Pods over SSH. The most common setup failure is forgetting to expose TCP port 22 when the Pod is launched. You can’t add the port to a Pod while it’s running, but you can add it by stopping the Pod, editing its template to expose TCP port 22, and restarting.
This page walks through the complete setup from scratch.
Requirements
If you haven’t done this yet, see Connect to a Pod with SSH for key generation instructions.
Step 1: Expose TCP port 22 at launch
Expose TCP port 22 before you start the Pod. If the Pod is already running, you can’t add the port while it’s running, so stop the Pod, edit the template to expose TCP port 22, and restart.
When deploying a Pod:
- Click Edit Template on your chosen GPU.
- In the Expose TCP Ports field, enter
22.
- Complete the deployment and start the Pod.
After the Pod starts, open its Connect tab and look for Direct TCP Ports. You will see a mapping like:
This is the public IP and port your agent will use to connect.
Step 2: Confirm the SSH daemon is running
Official Runpod templates such as Runpod PyTorch and Stable Diffusion start the SSH daemon automatically. No extra setup is needed.
Custom templates require you to start the SSH daemon manually. Add the following to your Docker start command:
If you already have a start command, replace sleep infinity at the end with this block.
Step 3: Connect your agent
Cursor runs on your local machine and connects to the Pod, while Claude Code runs on the Pod itself, so SSH is just how you open the terminal session to reach it.
Claude Code
SSH into the Pod, install Claude Code there, then start it from your project directory:
Use the native installer rather than npm install -g because official Runpod templates don’t ship Node.js.
Cursor
In Cursor, open the Command Palette and select Remote-SSH: Connect to Host. Enter:
Troubleshooting
Permission denied (publickey)
Verify that your public key is in your Runpod account settings. Paste the full key starting with ssh-ed25519, not the key fingerprint that starts with SHA256:. Confirm you are using the matching private key file with the -i flag.
Connection refused
Confirm TCP port 22 is listed in the Expose TCP Ports field of your Pod’s template. If it is missing, stop the Pod, add port 22 to the template, and restart. Then verify the SSH daemon is running inside the Pod by opening the web terminal and running:
RUNPOD_TCP_PORT_22 environment variable missing
TCP port 22 was not exposed when the Pod launched. Stop the Pod, expose the port in the template, and restart.
Pod IP address changed
Community Cloud Pods may receive a new IP address after a restart. If your agent loses its connection, find the updated IP in the Pod’s Connect tab and reconnect.
Next steps