Thursday, April 28, 2022

[SOLVED] Visual Studio: how can I debug a remote application which is running as root?

Issue

I have an application running on an Ubuntu instance in GCP. The program opens a server on port 80 so it has to be run as root.

I've setup my SSH connection successfully, but when I attempt to connect the process remotely I get the error:

Failed to attach to process: The .NET debugger has insufficient privileges to debug this process

enter image description here

I tried to start vsdbg with sudo .vs-debugger/vs2022/vsdbg, but I got the same error.

How can I attach to this process?


Solution

I found a workaround with a hack.

cd ~/.vs-debugger/vs2022/

mv vsdbg vsdbg.original

nano vsdbg

Copy this into that file:

#!/bin/bash
sudo ~/.vs-debugger/vs2022/vsdbg.original $@

Et voila.



Answered By - Ian Newson
Answer Checked By - Marilyn (WPSolving Volunteer)