Home > Software design >  VS Code debugging as root user
VS Code debugging as root user

Time:01-11

I have VS Code running on macOS connecting to a linux box where I am doing Go development. I am connecting via a user that has sudo privileges on the linux host. The root account is disabled on the remote host.

The application I am writing needs to run with root privileges. Is there a way to set vscode to elevate privileges when debugging the application? Or do I need to enable the root account for software development purposes?

CodePudding user response:

Below is the answer I received from the vs code developer team. This isn’t a feature and it will never be a feature.

In order to debug as a root, the debugger (dlv) must run as a root. Nether dlv, nor this extension aims to offer privilege escalation solutions. In remote debugging, dlv on the remote machine is externally managed, not by this extension, so it's out of scope. Moreover, this extension just communicates with the dlv on the remote host with DAP, which is not designed for security. So I am afraid this extension is not the right layer for privilege escalation. To debug as a root, as you already know, run dlv on the remote machine as a root (you may also need to set --only-same-user=false if the remote host is Linux) but protect access to the dlv server & the remote machine appropriately using proven security technologies. For local debugging, this is tracked in #558. But, I want to emphasize that debugging as a root still needs to be done with great care.

  •  Tags:  
  • Related