Issue Description
Attempting to run an application over OpenSSH using gsudo to run the process as a different user. The SSH session is already elevated. I receive an "Error: Unable to connect to the elevated service." error message when attempting to execute the process. This occurs if powershell.exe or cmd.exe are the default shell for OpenSSH server.
Steps to Reproduce
- Connect to Vagrant box over SSH using password authentication.
- Run the command
gsudo.exe -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe. This happens with all executeables that I've tested, not just my application.
- Supply password at the prompt.
Logs
Running from Powershell over OpenSSH
PS C:\Users\vagrant> gsudo.exe --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Invoking Shell: PowerShell Debug: Command Line: --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Command to run: C:\WINDOWS\system32\cmd.exe /v:on /s /c "c:\windows\system32\windowspowershell\v1.0\powershell.exe -NoLogo -NoProfile -Command "C:\Users\vagrant\forge-discover_windows_amd64.exe"" Debug: Using Console mode VT Debug: Caller PID: 7904 Debug: Caller SID: S-1-5-21-3744320041-3530587179-976868134-1000 Password for user WIN-5M2EKKKLBQD\vagrant2: *********** Debug: Starting process as WIN-5M2EKKKLBQD\vagrant2: C:\Program Files\gsudo\2.6.1\gsudo.exe --debug -u WIN-5M2EKKKLBQD\vagrant2 gsudoelevate 7904 S-1-5-21-3744320041-3530587179-976868134-1000 All 00:00:00 Debug: Service process started. Error: Unable to connect to the elevated service.
Running from CMD over OpenSSH
vagrant@WIN-R5DT7JM0D6P C:\Users\vagrant>gsudo.exe --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Invoking Shell: Cmd Debug: Command Line: --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Command to run: c:\windows\system32\cmd.exe /s /c "C:\Users\vagrant\forge-discover_windows_amd64.exe" Debug: Using Console mode VT Debug: Caller PID: 3636 Debug: Caller SID: S-1-5-21-1897239034-2482086053-3543861406-1000 Password for user WIN-R5DT7JM0D6P\vagrant2: *********** Debug: Starting process as WIN-R5DT7JM0D6P\vagrant2: C:\tools\gsudo\v2.6.1\gsudo.exe --debug -u WIN-R5DT7JM0D6P\vagrant2 gsudoelevate 3636 S-1-5-21-1897239034-2482086053-3543861406-1000 All 00:00:00 Debug: Service process started. Error: Unable to connect to the elevated service.
Context
- Windows version: Windows Server 2025 Datacenter Evaluation
- gsudo version: 2.6.1
Issue Description
Attempting to run an application over OpenSSH using gsudo to run the process as a different user. The SSH session is already elevated. I receive an "Error: Unable to connect to the elevated service." error message when attempting to execute the process. This occurs if powershell.exe or cmd.exe are the default shell for OpenSSH server.
Steps to Reproduce
gsudo.exe -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe. This happens with all executeables that I've tested, not just my application.Logs
Running from Powershell over OpenSSH
PS C:\Users\vagrant> gsudo.exe --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Invoking Shell: PowerShell Debug: Command Line: --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Command to run: C:\WINDOWS\system32\cmd.exe /v:on /s /c "c:\windows\system32\windowspowershell\v1.0\powershell.exe -NoLogo -NoProfile -Command "C:\Users\vagrant\forge-discover_windows_amd64.exe"" Debug: Using Console mode VT Debug: Caller PID: 7904 Debug: Caller SID: S-1-5-21-3744320041-3530587179-976868134-1000 Password for user WIN-5M2EKKKLBQD\vagrant2: *********** Debug: Starting process as WIN-5M2EKKKLBQD\vagrant2: C:\Program Files\gsudo\2.6.1\gsudo.exe --debug -u WIN-5M2EKKKLBQD\vagrant2 gsudoelevate 7904 S-1-5-21-3744320041-3530587179-976868134-1000 All 00:00:00 Debug: Service process started. Error: Unable to connect to the elevated service.Running from CMD over OpenSSH
vagrant@WIN-R5DT7JM0D6P C:\Users\vagrant>gsudo.exe --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Invoking Shell: Cmd Debug: Command Line: --debug -u vagrant2 C:\Users\vagrant\forge-discover_windows_amd64.exe Debug: Command to run: c:\windows\system32\cmd.exe /s /c "C:\Users\vagrant\forge-discover_windows_amd64.exe" Debug: Using Console mode VT Debug: Caller PID: 3636 Debug: Caller SID: S-1-5-21-1897239034-2482086053-3543861406-1000 Password for user WIN-R5DT7JM0D6P\vagrant2: *********** Debug: Starting process as WIN-R5DT7JM0D6P\vagrant2: C:\tools\gsudo\v2.6.1\gsudo.exe --debug -u WIN-R5DT7JM0D6P\vagrant2 gsudoelevate 3636 S-1-5-21-1897239034-2482086053-3543861406-1000 All 00:00:00 Debug: Service process started. Error: Unable to connect to the elevated service.Context