VSCode SSH as root

Oct 10, 2022

Credit: https://ponteshare.ch/2022/01/vscode-remote-ssh-as-root/

SSH can bridge through different servers with -J, so we can use our non-root user as a bridge to reach the root.

Append the following config to /etc/ssh/sshd_config to allow us to SSH into root on localhost:

Match Address 127.0.0.1 PermitRootLogin yes

Copy the key and restart the SSH service:

sudo cp ~/.ssh/authorized_keys /root/.ssh/ sudo service ssh restart

Then use this command in VSCode:

ssh -J <user>@<ssh-server-address> [email protected]