vscode remote-shh: switching user in the file explorer

Viewed 1053

I have VSCode with the extension remote-ssh installed. I connect to a remote host by username and IdentityFile.

To access certain files on the remote host, I have to switch users using su <user>. But when I switch users, I can only access the file in the terminal and not in the file explorer and therefore I'm unable to use the graphical editor of VSCode to edit my files.

1 Answers

You can modify your config file like this:

Host remote
....
RemoteCommand su otherUser

according to https://github.com/microsoft/vscode-remote-release/issues/690#issuecomment-993857961

but remember to manually add

"remote.SSH.useLocalServer": true,
"remote.SSH.enableRemoteCommand": true,

to your VSCode settings.json file,

and remember to test the command su otherUser in ssh terminal and make sure it doesn't ask for a password (which will not work with RemoteCommand)

For me, I use RemoteCommand sudo su otherUser and disable sudo password for my ssh user.

Took me a while to search answers and configure, now it works perfectly.

If you have any other questions, go to the issue and read the thread.

Related