New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure to open/write with sudo? #28

theoDiefenthal opened this Issue Jul 20, 2018 · 4 comments


None yet
3 participants

theoDiefenthal commented Jul 20, 2018

Hi there,

I have access to a remote system with a given user (not root).

This user has sudo priviliges, thus I can view/edit any file in an SSH session and I would like to use VS Code SSH FS plugin to edit some configuration files. But sadly, it doesn't allow me to write those config files due to missing permissions.

Would it be possible to include a "sudo" option in configuration which will kind of run any read/write operation with sudo?


This comment has been minimized.


SchoofsKelvin commented Sep 8, 2018

I'll be looking into this, but it's not planned right now.
Apparently it can be done, although I'll have to look into something mentioned here: mscdex/ssh2#287


This comment has been minimized.

ssanthos commented Sep 24, 2018

Would love to have support for this out of the box.

I'm currently working around this by always making a copy of the file I want to edit to a folder where I have write permissions, edit the file in VS Code, and then use a ssh terminal to copy the edited file back using sudo.


This comment has been minimized.


SchoofsKelvin commented Sep 25, 2018

As an easier workaround, you can use something like this:

chown -R root:sudo .;
chmod -R g+rwX .;

Assuming your user is in the sudo group, which it should be if it can use sudo, all the files in the current directory (and subdirectories) will be owned by root and the sudo group, with read/write permissions added for the group. Basically, anyone with sudo has access to everything in the current directory and below.

I think I found a (theoretical) way of accomplishing this, but I still need to implement and test it.


This comment has been minimized.


SchoofsKelvin commented Sep 27, 2018

This feature is now added (288f4ad) and published (extension version 1.10.0)

I'll add documentation (#43) for it soon, but here's a summary:

  • There's a new field sftpCommand added for sshfs configurations
  • If the field is absent, the extension will use the sftp subsystem, as it always did
  • If it's present, it'll run the given command instead of starting the given subsystem
  • For most distributions (e.g. Ubuntu), the default is /usr/lib/openssh/sftp-server (sftp subsystem)
  • You can change it to something else, e.g. sudo /usr/lib/openssh/sftp-server

An example configuration could be;

  "root": "/",
  "putty": "test",
  "name": "test",
  "sftpCommand": "sudo /usr/lib/openssh/sftp-server"

With this configuration, you'd be accessing files as root, or any other user, should you add the right parameter to the sudo command. Mind that creating files will also be in name of the given user, thus the ownership of the new file might be incorrect.

If there are any issues, feel free to post them here or make a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment