I am not able to save any files on my remote server with VSCode Remote SSH because I am not a root user.
I've followed the official documentation about how to set up ssh with SSH config file but even if my user as sudo privileges, I can't find any options in VSCode to save with sudo.
here is my SSH config file /Users/geoff/.ssh/config
:
Host gcpmain
User geoff
HostName <IP_ADDRESS>
IdentityFile ~/.ssh/gc_rsa
Obviously, when I try to save any files that require sudo I have this expected error message:
Failed to save 'default': Unable to write file (NoPermissions
(FileSystemError): Error: EACCES: permission denied, open
'/etc/nginx/sites-available/default')
Is there any way that I can force VSCode to save as sudo?
I recommend this VSCode extension: Save as Root in Remote SSH
Install the extension on a window opened with Remote-SSH and use "Save as Root" in the command palette instead of Ctrl+S.
Basically, it reads the contents of the editor and calls the sudo command to overwrite the file.