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? Thanks a lot for your answers! :)
I have faced the same question when I tried to edit the nginx conf files on my VPS. There is an open issue at github: Elevate rights on SSH remote, addressing similar problems.
As a temporary solution you can use WinScp - add sudo /path/to/sftp-server to your connection settings and then you can save changes to most (if not any) file. WinScp use sudo on login.