Torizon CMake project, Debug, run as "root"

Hello

I am trying to debug a Torizon CMake project, and run the application as “root”. So I’ve set "torizon_run_as": "root" in settings.json (as described in Workspace - Settings | Toradex Developer Center ). When trying to run and debug, I get the following error (log):

Executing task in folder MyProject: xonsh /home/kb/Workspaces/Torizon/Project/MyProject/.conf/service-check.xsh ssh - 2230 torizon 192.168.1.116 'echo ssh-ok' 

Exception occurred: Command '['sshpass', '-p', '-', 'ssh', '-p', '2230', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-o', 'PubkeyAuthentication=no', 'torizon@192.168.1.116', 'echo ssh-ok']' returned non-zero exit status 5.
Attempt 1/15: waiting for ssh...
Exception occurred: Command '['sshpass', '-p', '-', 'ssh', '-p', '2230', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-o', 'PubkeyAuthentication=no', 'torizon@192.168.1.116', 'echo ssh-ok']' returned non-zero exit status 5.
Attempt 2/15: waiting for ssh...

(more attempts follow)

With "torizon_run_as": "torizon" , everything works as expected.

What I’ve found out: service-check.xsh runs twice during “Run and Debug”, the first time on port 22, tt passes. The second time on port 2230 it fails, as can be seen in the log above.

If I skip service-check.xsh (by just inserting sys.exit(0)in all cases) everything works, my app runs as root and I can debug, no problems or issues occurred so far. This is my workaround for the moment.

So I have a workaround, but a real solution would be nice.

Thank you.

# tdx-info

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.6.119-7.5.0-00057-g86497e203ba0 #1-Torizon SMP PREEMPT Mon Jun 30 14:11:55 UTC 2025
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.0/torizon/7be71a655bcf1a49919dc0d9709c05455c04734df5e2ed01203d13c8b16f76fa/0
Distro name:              NAME="Torizon OS Upstream"
Distro version:           VERSION_ID=7.5.0-build.30
Distro variant:           VARIANT="Docker"
Hostname:                 apalis-imx6-08535054
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Apalis iMX6Q/D Module on Apalis Evaluation Board
Toradex version:          0027 V1.1B
Serial number:            08535054
Processor arch:           armv7l
------------------------------------------------------------

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Based on your configuration and error logs, this appears to be an issue with SSH connectivity when using the torizon_run_as setting with “root” user. The service check is failing on port 2230, which is used for container SSH connections during debugging(1).

Understanding the Issue

The torizon_run_as setting controls which user runs the application inside the debug container(2). When set to “root”, it changes the container’s runtime user configuration, which can affect SSH connectivity during the debugging process.

The error you’re seeing occurs because the extension is trying to establish an SSH connection to the debug container on port 2230, but this fails when the container is configured to run as root(1).

Port Configuration

For the Torizon IDE Extension to work correctly, several ports need to be accessible between your development machine and the target device(1):

  • 22 (Dev Board SSH Connection)
  • 2375 (Docker API)
  • 5002 (Local Docker Registry)
  • 2222 (Container SSH Connection)

The error shows port 2230 being used, which suggests a custom SSH port configuration.

Debugging Process

During the debugging process, the extension performs several tasks including building the debug container and establishing SSH connections for remote debugging(3). The torizon_debug_ssh_port setting controls the port used for SSH connections to the debug container(2).

Potential Solutions

  1. Check SSH Port Configuration: Verify that the torizon_debug_ssh_port setting in your .vscode/settings.json matches the expected port (typically 2222)(2).

  2. Container User Configuration: When using torizon_run_as: "root", ensure that the debug container is properly configured to allow SSH access for the root user.

  3. Network Connectivity: Test if you can manually SSH to the device on the configured debug port when the container is running as root.

Alternative Approach

If you need root privileges for your application, consider using sudo within the application code instead of changing the torizon_run_as setting. The default torizon user has root privileges and can execute sudo commands(4).

Your workaround of bypassing the service check works because it skips the SSH connectivity verification, but the proper solution would involve ensuring the SSH configuration is compatible with the root user setup.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.