Michel Feinstein
Michel Feinstein

Reputation: 14296

How to Remotely Debug code as sudo with CLion?

I am using CLion in my Windows PC to run and debug code on a Raspberry Pi, using the Remote development option with GDB.

How can I make that remote code on my Raspberry Pi run as root when I debug it?

Upvotes: 0

Views: 1672

Answers (2)

Thibaut M.
Thibaut M.

Reputation: 31

there is a way, but not recommended, you can log as root in clion.

  1. Enable root login via SSH
    • edit ssh_config file: vim /etc/ssh/sshd_config
    • add this line PermitRootLogin yes
    • save the file
    • restart the ssh server systemctl restart sshd
  2. Set a root password if there isn't one already: sudo passwd root
  3. In Clion configure the Remote Host to login as root (Files->setting->Build, Execution, Deployment->Toolchains->Credentials). Procedure described here.

This worked for me.

Upvotes: 0

Jan Skarupa
Jan Skarupa

Reputation: 11

I assume you are using Full Remote Mode i.e. you created new toolchain with Remote Host option as described here.

There is no way to run GDB with sudo. But you can make CLion ssh into your raspberry with root account. Just change settings in Credentials section. (Also make sure you have SSH root login enabled.)

If you ever need more control over GDB, go with gdbserver.

Upvotes: 1

Related Questions