Debug with SSH
Use debug mode to troubleshoot remote builds
You can use the Harness CI Re-run in Debug Mode feature to quickly and securely troubleshoot remote builds by SSH-ing into a debug session on the build's remote host. With debug mode, you:
Get temporary, secure access to the build environment without the need for permanent permission changes.
Troubleshoot directly in the build environment, not a recreation on your local machine.
Troubleshoot in real time, rather than waiting for logs to output after each build.
You can also use Re-run in Debug Mode to troubleshoot local builds.
Debug mode requirements
If debug mode is not available for your pipeline, you might consider using Harness AI.
Enable debug mode
If your build meets the debug mode requirements, use these steps to use debug mode for builds on Harness Cloud, self-managed VM, or Kubernetes cluster build infrastructures.
Create a Harness API key and token with
pipeline executionpermissions. You must have pipeline execution permissions at the account scope in order for the token to have those permissions.Navigate to the Builds, Executions, or Execution History page.
Locate the build you want to troubleshoot, select More Options (⋮), and select Re-run in Debug Mode.

Wait while the build runs. If the Run step fails, the build stops and generates log output with an SSH command you can use to SSH into the session on the remote host.
The SSH command is formatted as follows. Replace
{harness pat}with your token that haspipeline executionpermissions. Copy the exact command from the log — the host shown may be a specific node such asssh1.harness.io.
While in the debug session, use the CLI to reproduce and troubleshoot the issue on the remote host.
To terminate the debug session, abort the build, and then run a new build to determine if the issue is resolved. Sessions automatically terminate after one hour or at the step timeout limit, whichever occurs first.
If your build meets the debug mode requirements, use these steps to use debug mode for builds running on local runner build infrastructure, on Linux or macOS. The Run step executes directly on the host machine (or its Docker runtime), so tmate must be installed on that host.
Download the tmate binary matching your runner host's OS and architecture from Harness tmate releases.
Operating SystemArchitectureExtract the archive on the runner's host machine, place the
tmatebinary in a dedicated directory (for example/Users/<username>/bin/tmateon macOS or/opt/harness/bin/tmateon Linux), and make it executable:In your CI stage, under Infrastructure, set Platform to the
osandarchthat match your runner host (for example,os: Linux/arch: Amd64, oros: MacOS/arch: Arm64).Under Infrastructure > Advanced > Shared Paths, add the host directory containing the
tmatebinary (for example,/Users/<username>/binon macOS or/opt/harness/binon Linux). This mounts the directory on the runner host so it is accessible inside the step's execution container.In your Run step, expand Environment Variables and add the
TMATE_PATHvariable with the full absolute path to the binary (for example,/Users/<username>/bin/tmateor/opt/harness/bin/tmate). This path must sit inside the Shared Paths directory from the previous step.In your CI stage, under Advanced, add a Delegate Selector tag matching your local delegate. This pins the build to the host where tmate is installed. Go to define a Docker build infrastructure to configure delegate selectors.
Create a Harness API key and token with
pipeline executionpermissions. You must have pipeline execution permissions at the account scope in order for the token to have those permissions.Navigate to the Builds, Executions, or Execution History page.
Locate the build you want to troubleshoot, select More Options (⋮), and select Re-run in Debug Mode.

Builds page with the More Options menu open and Re-run in Debug Mode highlighted Wait while the build runs. If the Run step fails, the build stops and generates log output with an SSH command you can use to SSH into the debug session on the runner host.
The SSH command is formatted as follows. Replace
{harness pat}with your token that haspipeline executionpermissions. Copy the exact command from the log — the host shown may be a specific node such asssh1.harness.io.
Run step logs showing the SSH command for the debug session While in the debug session, use the CLI to reproduce and troubleshoot the issue.
To terminate the debug session, abort the build, and then run a new build to determine if the issue is resolved.
Last updated
Was this helpful?