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 isn't 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.
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 on local runner build infrastructures.
Download and install tmate on the runner's host machine.
If necessary, mount the install path. By default, Harness mounts the
/addonpath. If you installed tmate elsewhere, you need to mount that path.In your CI pipeline, add the environment variable
TMATE_PATHto your Run step. Set the value to the tmate mount path, such as/addon/tmate.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 debug session.
The SSH command is formatted as follows. Replace
{harness pat}with your token that haspipeline executionpermissions.
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. Sessions automatically terminate after one hour or at the step timeout limit, whichever occurs first.
Last updated
Was this helpful?