I’m running a simple script in a VSCode task like this:
.vscode/say_hello.sh:
echo Hello World, this is $(whoami)!
.vscode/tasks.yaml:
{
"version": "2.0.0",
"tasks": [
{
"label": "Say Hello",
"type": "shell",
"command": "${workspaceFolder}/.vscode/say_hello.sh"
},
]
}
When I run this task in VSCode normally I get the expected output: Hello World, this is monsdar!
. But instead I’d like to run this script as a different user, let’s call him bobby
.
Some more detail about my environment:
- Running VSCode on a Windows machine, connected via the “Remote: SSH” plugin to an Ubuntu 22.04 host
- My user has sudo permissions
- The user I’d like to turn into does not have sudo permissions
Is this possible? What’s the most elegant way? At best I can put this task into my repository and other eligible users can run as that user as well. Perhaps even on a different machine.