Report this

What is the reason for this report?

How to edit files with VS Code remote-ssh with non-root user?

Posted on April 24, 2023

I’ve been using VS Code remote SSH to ssh into my droplets and edit files when needed, per this tutorial: https://www.digitalocean.com/community/tutorials/how-to-use-visual-studio-code-for-remote-development-via-the-remote-ssh-plugin

However, up till now I was using a root user. For security purposes, I’m trying to disable root access: https://www.digitalocean.com/community/tutorials/how-to-disable-root-login-on-ubuntu-20-04

But when I ssh with a non-root user, I’m only able to view files with VS Code. If I want to edit/save my changes, I have to use sudo, like so: sudo code filename, and this throws me an error: sudo: code: command not found

I found a couple of threads discussing this issue, but no resolutions (see below). If anyone has any pointers, I’d appreciate it. I’d really hate having to go back to nano and Vim :)

https://github.com/microsoft/vscode-remote-release/issues/1688 https://github.com/microsoft/vscode/issues/48659

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.