Search code examples
sshvisual-studio-code

How to edit files from remote server as root while ssh-ing from VS code?


I'm connecting to a virtual machine in Azure using Remote-SSH extension in Visual Studio Code. Problem is I can't ssh as root, but need root privileges to edit some files in /etc folder. 'Sudo-ing' in the terminal window has no effect. I'm thinking changing the file permissions would allow me to edit the files as a normal user, but I'd rather avoid that. Any ideas how I could edit the files in VS Code then?


Solution

  • I ended up using SSH FS extension instead. Created a new configuration with my connection details (host, username and private key). Then in File > Preferences > Settings > Extensions > SSH FS Configuration > Sshfs: Configs I added "sftpSudo": true, which allowed me to edit the files as root.

    p.s. I'll leave the question open for a while longer, just in case somebody can explain how I can achieve this using Remote-SSH extension.