I have two machines:
- A host machine (Windows 11) running VS Code
- A Hyper-V guest VM (Windows 11): OpenSSH Server installed, running VS Code Server with a Python project
pythonWebApp
I'd like to ssh the guest by VS Code's SSH Remote extension and debug the pythonWebApp project remotely.
Current behavior is that the SSH connection succeeds, but environment variables differ - for example, PATH in the guest machine has the Python paths.
The following is the Windows Terminal outputs in the guest VM:
PS C:\Users\kusha> $env:PATH
C:\Users\kusha\AppData\Local\Programs\Python\Python313\Scripts\;C:\Users\kusha\AppData\Local\Programs\Python\Python313\;C:\Users\kusha\AppData\Local\Programs\Python\Launcher\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\kusha\AppData\Local\Programs\Python\Launcher\;C:\Users\kusha\AppData\Local\Microsoft\WindowsApps;
PS: I added these Python paths to system variable PATH manually.
PATH in ssh session lacks these Python paths.
The following is the Terminal Window outputs in VS Code:
PS C:\Users\kusha\pl-python\pythonWebApp> $env:PATH
c:\Users\kusha\.vscode-server\cli\servers\Stable-cb0c47c0cfaad0757385834bd89d410c78a856c0\server\bin\remote-cli;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\kusha\AppData\Local\Microsoft\WindowsApps;;c:\Users\kusha\.vscode-server\extensions\ms-python.debugpy-2025.10.0-win32-x64\bundled\scripts\noConfigScripts;c:\Users\kusha\.vscode-server\data\User\globalStorage\github.copilot-chat\debugCommand
Apparently, due to the lack of Python environment variables in the ssh session, VS Code cannot perform any Python related operation.
PS: using a pure ssh session (i.e. not through VS Code) has a similar problem.
Question: how can I make the ssh session use the same environment variables as the guest? Alternatively, is there a way to automatically set environment variables when ssh connect?
Thanks very much.