Skip to content
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

Can't connect to non-admin Windows account (Get-CimInstance PermissionDenied) #2648

Open
ericblade opened this issue Mar 30, 2020 · 42 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug plan-review PM-highlighted item determined to be P1 or P2 ssh Issue in vscode-remote SSH
Milestone

Comments

@ericblade
Copy link

ericblade commented Mar 30, 2020

  • VSCode Version: 1.43.2
  • Local OS Version: Windows 18363.720
  • Remote OS Version: Windows 18363.720
  • Remote Extension/Connection Type: SSH

Steps to Reproduce:

  1. Attempt to login to remote Windows server

Does this issue occur when you try this locally?: This is a connection specific issue
Does this issue occur when you try this locally and all extensions are disabled?: This is a connection specific issue

Attempting to use VSC remote with a remote SSH server on Windows. I've installed the Windows 10 OpenSSH server using Add/Remove features. I can connect to it using my regular Linux host, my WSL host, and native windows ssh.

When I attempt to connect to this host with VSCode, first it asks me what OS i'm using, I enter Windows.

Then it asks for my password. It chugs along for a little while, with the following log output, and then stops with a modal "Could not establish connection to 'arcade.lan'."

Seems unrelated to #2198, I think?

[19:26:15.859] Log Level: 2
[19:26:15.861] remote-ssh@0.51.0
[19:26:15.861] win32 x64
[19:26:15.863] SSH Resolver called for "ssh-remote+arcade.lan", attempt 1
[19:26:15.863] SSH Resolver called for host: arcade.lan
[19:26:15.863] Setting up SSH remote "arcade.lan"
[19:26:15.880] Using commit id "0ba0ca52957102ca3527cf479571617f0de6ed50" and quality "stable" for server
[19:26:15.882] Install and start server if needed
[19:26:34.124] Checking ssh with "ssh -V"
[19:26:34.160] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[19:26:34.161] Remote command length: 7544/8192 characters
[19:26:34.164] Running script with connection command: ssh -T -D 8350 arcade.lan powershell -ExecutionPolicy Unrestricted -NoLogo -NoProfile -NonInteractive -Command "powershell -ExecutionPolicy Unrestricted -NoLogo -NoProfile -NonInteractive -EncodedCommand $([Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('CmVjaG8gImI2NDIxNDJjZmY3MzogcnVubmluZyIKJFByb2dyZXNzUHJlZmVyZW5jZSA9ICdTaWxlbnRseUNvbnRpbnVlJwokY29tbWl0SWQgPSAnMGJhMGNhNTI5NTcxMDJjYTM1MjdjZjQ3OTU3MTYxN2YwZGU2ZWQ1MCcKCiR2c2NvZGVBcmNoID0gaWYgKCgkZW52OlBST0NFU1NPUl9BUkNISVRFQ1RVUkUgLWVxICdBTUQ2NCcpIC1vciAoJGVudjpQUk9DRVNTT1JfQVJDSElURUNUVVJFIC1lcSAnSUE2NCcpKSB7ICd4NjQnIH0gZWxzZSB7ICdpYTMyJyB9Cgokc2VydmVyUm9vdCA9IChKb2luLVBhdGggKFJlc29sdmUtUGF0aCB+KSAnLnZzY29kZS1zZXJ2ZXInKQokZW52OlZTQ09ERV9BR0VOVF9GT0xERVI9JHNlcnZlclJvb3QKJGxvZ2ZpbGUgPSAiJHNlcnZlclJvb3RcLiRjb21taXRJZC5sb2ciCiRzZXJ2ZXJEaXIgPSAiJHNlcnZlclJvb3RcYmluXCRjb21taXRJZCIKJHF1YWxpdHkgPSAnc3RhYmxlJwokdGVsZW1ldHJ5ID0gIiIKJGV4dGVuc2lvbnMgPSAiIgoKZnVuY3Rpb24gZ2V0U3NoZFBhcmVudFBpZCB7CiRjdXJyZW50UElEID0gJFBJRAp3aGlsZSAoJFRydWUpIHsKJHBhcmVudFBJRCA9IChHZXQtQ2ltSW5zdGFuY2Ugd2luMzJfcHJvY2VzcyB8ID8gcHJvY2Vzc2lkIC1lcSAkY3VycmVudFBJRCkucGFyZW50cHJvY2Vzc2lkCmlmICghJHBhcmVudFBJRCkgewplY2hvICJDb3VsZCBub3QgZmluZCBhbiBzc2hkIHBhcmVudCBvZiB0aGlzIHByb2Nlc3MiCmV4aXQgMAp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xhdGZvcm09PXdpbmRvd3M9PSIKZWNobyAiYjY0MjE0MmNmZjczOiBlbmQiCgoKCmVjaG8gIkluc3RhbGwgc2NyaXB0IGlzICRwaWQsIHdhdGNoaW5nIHNzaGQgcGFyZW50ICRzc2hkUElEIgp3aGlsZSAoJFRydWUpIHsKZXhpdElmTmVlZGVkClN0YXJ0LVNsZWVwIDMwCn0K')))))"  # RemoteSSHConfigurationScript
[19:26:34.166] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[19:26:34.241] > 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> �]0;C:\WINDOWS\System32\cmd.exe�
[19:26:34.242] Got some output, clearing connection timeout
[19:26:34.247] > 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
[19:26:34.449] > DockerUser@arcade.lan's password: 
[19:26:34.449] Showing password prompt
[19:26:41.859] Got password response
[19:26:41.860] "install" wrote data to terminal: "******"
[19:26:41.872] > 
> 
[19:26:42.507] > #< CLIXML
> 
[19:26:42.516] > b642142cff73: running
> 
[19:26:47.880] > Could not find an sshd parent of this process
[19:26:47.887] > 
> <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
> <Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCust
> omObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"
> ><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC
> ><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1
> "><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing m
> odules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T
> ><SR>-1</SR><SD> </SD></PR></MS></Obj><S S="Error">Get-CimInstance : Access deni
> ed _x000D__x000A_</S><S S="Error">At line:19 char:15_x000D__x000A_</S><S S="Erro
> r">+ $parentPID = (Get-CimInstance win32_process | ? processid -eq $curren ..._x
> 000D__x000A_</S><S S="Error">+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D
> __x000A_</S><S S="Error">    + CategoryInfo          : PermissionDenied: (root\c
> imv2:win32_process:String) [Get-CimInstance], CimException_x000D__x000A_</S><S S
> ="Error">    + FullyQualifiedErrorId : HRESULT 0x80041003,Microsoft.Management.I
> nfrastructure.CimCmdlets.GetCimInstanceCommand_x000D__x000A_</S><S S="Error"> _x
> 000D__x000A_</S></Objs>
[19:26:48.207] "install" terminal command done
[19:26:48.208] Install terminal quit with output: 000D__x000A_</S></Objs>
[19:26:48.208] Received install output: 000D__x000A_</S></Objs>
[19:26:48.209] Stopped parsing output early. Remaining text: 000D__x000A_</S></Objs>
[19:26:48.210] Failed to parse remote port from server output
[19:26:48.210] Resolver error: 
[19:26:48.216] ------
@ericblade ericblade changed the title attempting to use windows as a remote host fails with no obvious error attempting to use windows as a remote host fails with Failed to parse remote port from server output Mar 31, 2020
@roblourens
Copy link
Member

On the remote, if you open powershell, are you able to run this command? (Get-CimInstance Win32_OperatingSystem).Version It's saying PermissionDenied for that command, but I don't think you should need admin privileges for that one as far as I know.

@roblourens roblourens added the info-needed Issue requires more information from poster label Mar 31, 2020
@ericblade
Copy link
Author

ericblade commented Apr 1, 2020

logged into the remote with remote desktop:

image

logged into the remote via ssh:

image

... neither were run with specifically requesting admin. perhaps something in my openssh configuration is wonky? i just added the server from Add/Remove Components, rebooted, and then made sure the service was running in taskmanager, then used it.

@roblourens
Copy link
Member

Are you the same user in both? In the remote desktop case is that an Admin powershell window?

@ericblade
Copy link
Author

same user.. i'm pretty sure it was not an admin powershell, but i will re-run it just to make sure

image

So, it looks like I have permission to run that command when connected via RDP to the machine, but not when connected via SSHD .. not sure how that works exactly, I'm no expert in Windows permissions. I'm probably not even a novice in Windows permissions :)

@roblourens
Copy link
Member

Can you try running this snippet on both ends?

$SecurityPrinciple = New-Object -TypeName System.Security.Principal.WindowsPrincipal -ArgumentList ([System.Security.Principal.WindowsIdentity]::GetCurrent())
$RolesHash = @{}
[System.Enum]::GetNames(“System.Security.Principal.WindowsBuiltInRole”) | ForEach-Object {
	$RolesHash[$_] = $SecurityPrinciple.IsInRole([System.Security.Principal.WindowsBuiltInRole]::$_)
}

$RolesHash

[System.Security.Principal.WindowsIdentity]::GetCurrent()

@ericblade
Copy link
Author

From RDP

PS C:\WINDOWS\system32> $SecurityPrinciple = New-Object -TypeName System.Security.Principal.WindowsPrincipal -ArgumentList ([System.Security.Principal.WindowsIdentity]::GetCurrent())                                                          PS C:\WINDOWS\system32> $RolesHash = @{}                                                                                PS C:\WINDOWS\system32> [System.Enum]::GetNames("System.Security.Principal.WindowsBuiltInRole") | ForEach-Object {
>> $RolesHash[$_] = $SecurityPrinciple.IsInRole([System.Security.Principal.WindowsBuiltInRole]::$_)
>> }                                                                                                                    PS C:\WINDOWS\system32>                                                                                                 PS C:\WINDOWS\system32> $RolesHash
Name                           Value
----                           -----
Replicator                     False
PrintOperator                  False
PowerUser                      False
Guest                          False
AccountOperator                False
SystemOperator                 False
BackupOperator                 False
Administrator                  False
User                           True


PS C:\WINDOWS\system32>                                                                                                 PS C:\WINDOWS\system32> [System.Security.Principal.WindowsIdentity]::GetCurrent()                                    

AuthenticationType : NTLM
ImpersonationLevel : None
IsAuthenticated    : True
IsGuest            : False
IsSystem           : False
IsAnonymous        : False
Name               : ARCADE\dockeruser
Owner              : S-1-5-21-3583042812-2210650346-111016193-1004
User               : S-1-5-21-3583042812-2210650346-111016193-1004
Groups             : {S-1-5-21-3583042812-2210650346-111016193-513, S-1-1-0, S-1-5-32-545, S-1-5-4...}
Token              : 884
AccessToken        : Microsoft.Win32.SafeHandles.SafeAccessTokenHandle
UserClaims         : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: ARCADE\dockeruser,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid:
                     S-1-5-21-3583042812-2210650346-111016193-1004,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid:
                     S-1-5-21-3583042812-2210650346-111016193-513,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:
                     S-1-5-21-3583042812-2210650346-111016193-513...}
DeviceClaims       : {}
Claims             : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: ARCADE\dockeruser,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid:
                     S-1-5-21-3583042812-2210650346-111016193-1004,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid:
                     S-1-5-21-3583042812-2210650346-111016193-513,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:
                     S-1-5-21-3583042812-2210650346-111016193-513...}
Actor              :
BootstrapContext   :
Label              :
NameClaimType      : http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
RoleClaimType      : http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid



PS C:\WINDOWS\system32>

from sshd

PS C:\Users\dockeruser> $SecurityPrinciple = New-Object -TypeName System.Security.Principal.WindowsPrincipal -ArgumentList ([System.Security.Principal.WindowsIdentity]::GetCurrent())
PS C:\Users\dockeruser> $RolesHash = @{}
PS C:\Users\dockeruser> [System.Enum]::GetNames("System.Security.Principal.WindowsBuiltInRole") | ForEach-Object {
>> $RolesHash[$_] = $SecurityPrinciple.IsInRole([System.Security.Principal.WindowsBuiltInRole]::$_)
>> }
PS C:\Users\dockeruser>
PS C:\Users\dockeruser> $RolesHash

Name                           Value
----                           -----
Replicator                     False
PrintOperator                  False
PowerUser                      False
Guest                          False
AccountOperator                False
SystemOperator                 False
BackupOperator                 False
Administrator                  False
User                           True


PS C:\Users\dockeruser>
PS C:\Users\dockeruser> [System.Security.Principal.WindowsIdentity]::GetCurrent()


AuthenticationType : NTLM
ImpersonationLevel : None
IsAuthenticated    : True
IsGuest            : False
IsSystem           : False
IsAnonymous        : False
Name               : ARCADE\dockeruser
Owner              : S-1-5-21-3583042812-2210650346-111016193-1004
User               : S-1-5-21-3583042812-2210650346-111016193-1004
Groups             : {S-1-5-21-3583042812-2210650346-111016193-513, S-1-1-0, S-1-5-32-545, S-1-5-2...}
Token              : 3052
AccessToken        : Microsoft.Win32.SafeHandles.SafeAccessTokenHandle
UserClaims         : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: ARCADE\dockeruser, http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: S-1-5-21-3583042812-2210650346-111016193-1004,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid: S-1-5-21-3583042812-2210650346-111016193-513, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-5-21-3583042812-2210650346-111016193-513...}
DeviceClaims       : {}
Claims             : {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: ARCADE\dockeruser, http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid: S-1-5-21-3583042812-2210650346-111016193-1004,
                     http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid: S-1-5-21-3583042812-2210650346-111016193-513, http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid: S-1-5-21-3583042812-2210650346-111016193-513...}
Actor              :
BootstrapContext   :
Label              :
NameClaimType      : http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
RoleClaimType      : http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid



PS C:\Users\dockeruser>

@roblourens roblourens changed the title attempting to use windows as a remote host fails with Failed to parse remote port from server output attempting to use windows as a remote host fails (Get-CimInstance PermissionDenied) Apr 3, 2020
@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug ssh Issue in vscode-remote SSH and removed info-needed Issue requires more information from poster labels Apr 3, 2020
@roblourens roblourens self-assigned this Apr 3, 2020
@roblourens
Copy link
Member

Thanks for trying that. I have no clue what's going on, I'll have to experiment some more.

@roblourens roblourens added this to the April 2020 milestone Apr 3, 2020
@ericblade
Copy link
Author

If it helps at all, it's a pretty basic installation of Windows 10 Pro, it's got Docker for Windows installed, a Plex Media Server, and a bunch of Docker services that handle home automation tasks. That's really about it. I decided I wanted to try VSCode remote to it, now that it supports Windows. ssh wouldn't work with the default account which has no password on it, so i used the account that was setup for Docker volume sharing (since Docker also doesn't work with accounts that have no password) ... i don't know what else I could add that might help.

@roblourens
Copy link
Member

I can repro. Basically get-ciminstance will work locally but not through an ssh session. I didn't realize that the permissions model works like that and had only tested it locally in a non-admin account.

@roblourens roblourens changed the title attempting to use windows as a remote host fails (Get-CimInstance PermissionDenied) Can't connect to non-admin Windows account (Get-CimInstance PermissionDenied) Apr 13, 2020
@jvihrial
Copy link

jvihrial commented Apr 15, 2020

yes, I can repro this easily, ssh to windows box, open powershell and execute the command: (Get-CimInstance Win32_OperatingSystem).Version, you get back:
PS C:\Users\testuser> (Get-CimInstance Win32_OperatingSystem).Version

Get-CimInstance : Access denied
At line:1 char:2
+ (Get-CimInstance Win32_OperatingSystem).Version
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (root\cimv2:Win32_OperatingSystem:String) [Get-CimInstance], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

@wpbrown
Copy link

wpbrown commented Apr 20, 2020

Connecting via SSH is a network logon vs interactive logon locally or via RDP. I think the credentials of the SSH session can't be forwarded to the local COM server to use CIM.

@ericblade
Copy link
Author

Confirming that the destination account is a Local Standard account type.

@wpbrown
Copy link

wpbrown commented Apr 21, 2020

I'm reproducing with a Local Standard account. Local Admin account works fine.

@roblourens roblourens modified the milestones: April 2020, May 2020 Apr 28, 2020
@Conafmau
Copy link

Grant permission to execute Get-CimInstance, but still dont work.

Grant permission:
https://docs.bmc.com/docs/display/public/btco100/Setting+WMI+user+access+permissions+using+the+WMI+Control+Panel

New error:
...
[19:22:45.843] Received install output: dce0ba885507##32##
[19:22:45.845] Resolver error: The VS Code Server failed to start

@roblourens roblourens modified the milestones: May 2020, June 2020 May 31, 2020
@phit
Copy link

phit commented Jun 8, 2020

Is there any known workaround for this issue? Some patch I could try? Thanks.

@ericblade
Copy link
Author

I don't know if anyone's found anything else out yet, but i made a second admin account on the machine. :|

@bamurtaugh bamurtaugh added the plan-review PM-highlighted item determined to be P1 or P2 label Nov 20, 2020
@roblourens roblourens modified the milestones: January 2021, On Deck Jan 28, 2021
@bluepotatoes
Copy link

I am having this exact same issue with CimInstance privileges. Haven't been able to find a workaround that works.

@metablaster
Copy link

metablaster commented Apr 1, 2021

Here is slightly different and shorter approach from what @faltrock-abone described: (+1 btw!)

  1. Run compmgmt.msc as Administrator
  2. Select WMI control node -> More actions -> properties
  3. In the Security tab add only the standard user that you'll use for SSH
  4. The rest is same, edit security property for this user:
    • Enable Account and Remote Enable rights \ applies to this namesapce and subnamespaces

What's the difference or why doing it this way?
WinRMRemoteWMIUsers__ group is added after you've setup WinRM (not everybody does), this way you skip that part:
https://docs.microsoft.com/en-us/windows/win32/winrm/authentication-for-remote-connections

Another difference is that you affect only single standard user account.

edit:
Another solution to affect multiple standard users would be to add specific users to Remote management users group, then add this group to WMI.
Why? this group has required permissions already set, you only add users to it, and add it to WMI security without additional steps that are needed for single user.

@FulChou
Copy link

FulChou commented Apr 10, 2021

hello, I get the same problem, I use vscode to connect my windows server in my MacPro by ssh. i can connect when the remote is Administrator, but no my own user account.
but, I can use ssh login with my own username by terminal.

this is log, when I try to connect my own username:

[15:25:40.663] Log Level: 2
[15:25:40.665] remote-ssh@0.65.1
[15:25:40.665] darwin x64
[15:25:40.666] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a2257494e2d363539503935564a49564c227d", attempt 1
[15:25:40.666] "remote.SSH.useLocalServer": false
[15:25:40.666] "remote.SSH.showLoginTerminal": false
[15:25:40.667] "remote.SSH.remotePlatform": {"18862_ocr":"linux","raspberrypi":"linux","inpluslab":"linux","WIN-659P95VJIVL_admin":"windows"}
[15:25:40.667] "remote.SSH.sshPath": undefined
[15:25:40.667] "remote.SSH.sshConfigurationFile": undefined
[15:25:40.667] "remote.SSH.useFlock": true
[15:25:40.667] "remote.SSH.lockfilesInTmp": false
[15:25:40.667] "remote.SSH.localServerDownload": auto
[15:25:40.667] "remote.SSH.remoteServerListenOnSocket": false
[15:25:40.668] "remote.SSH.showLoginTerminal": false
[15:25:40.668] "remote.SSH.defaultExtensions": []
[15:25:40.668] SSH Resolver called for host: WIN-659P95VJIVL
[15:25:40.668] Setting up SSH remote "WIN-659P95VJIVL"
[15:25:40.677] Using commit id "c185983a683d14c396952dd432459097bc7f757f" and quality "stable" for server
[15:25:40.681] Install and start server if needed
[15:25:42.151] Checking ssh with "ssh -V"
[15:25:42.158] > OpenSSH_8.1p1, LibreSSL 2.7.3

[15:25:42.161] Remote command length: 5986/8192 characters
[15:25:42.161] Running script with connection command: ssh -T -D 57770 -o ConnectTimeout=15 'WIN-659P95VJIVL' powershell
[15:25:42.923] > ZhouFu@172.18.166.44's password:
[15:25:42.923] Got some output, clearing connection timeout
[15:25:42.924] Showing password prompt
[15:25:56.234] Got password response
[15:25:56.234] "install" wrote data to terminal: "**********"
[15:25:56.247] >
[15:25:59.027] > Windows PowerShell

��Ȩ���� (C) Microsoft Corporation����������Ȩ����

(base) PS C:\Users\ZhouFu>
(base) PS C:\Users\ZhouFu> $uuid="c82d9a7e983f"
(base) PS C:\Users\ZhouFu> "${uuid}: running"
c82d9a7e983f: running
(base) PS C:\Users\ZhouFu> "c82d9a7e983f: pauseLog"
c82d9a7e983f: pauseLog
[15:26:00.136] > m
[15:26:00.142] > ain
[15:26:05.111] > gcim : �ܾ�����
����λ�� ��:4 �ַ�: 6

  • $u_=(gcim win32_process | ? processid -eq $t_).parentprocessid
  •  ~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : PermissionDenied: (root\cimv2:win32_process:String) [Get-CimInstance], CimException
    • FullyQualifiedErrorId : HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

[15:26:05.119] > no sshd parent proc
[15:26:05.127] >
[15:26:05.448] "install" terminal command done
[15:26:05.448] Install terminal quit with output: no sshd parent proc
[15:26:05.448] Received install output: no sshd parent proc
[15:26:05.449] Stopped parsing output early. Remaining text: no sshd parent proc
[15:26:05.449] Failed to parse remote port from server output
[15:26:05.452] Resolver error: Error:
at Function.Create (/Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:1:64328)
at Object.t.handleInstallOutput (/Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:1:63022)
at q (/Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:1:296373)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:1:294221
at async Object.t.withShowDetailsEvent (/Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:1:407055)
at async Object.t.resolve (/Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:1:297912)
at async /Users/vincent/.vscode/extensions/ms-vscode-remote.remote-ssh-0.65.1/out/extension.js:127:110485
[15:26:05.476] ------

I can get success when using Administrator
image

thank you for your help !!!

@bobwng
Copy link

bobwng commented Jul 16, 2021

Met exactly same issue as @CSU-FulChou mentioned above. Administrator account is OK but other admin group users are not.

Tried the solution @metablaster provided above, the issue is still there.

@Silver-Fang
Copy link

Same issue. Still not fixed for 21 months???

@Sidneys1
Copy link

Steps that worked for me:

  1. Open compmgmt.msc as an elevated user.
  2. Expand "Services and Applications", select "WMI Control", then right-click "WMI Control"→"Properties"
  3. Select the "Security" tab and click the "Security" button.
  4. In the "Security for Root" window that appears, click "Advanced".
  5. Click "Add". Click "Select a principal".
  6. Type "Remote Management Users" and click "Validate names". This will resolve the group name, then click OK.
  7. Select "Applies to:"→"This namespace and subnamespaces". Check all permissions and click OK.
  8. Click OK out through all of the remaining dialogs.
  9. Add your user to the "Remote Management Users" group if you haven't already.
  10. Restart the OpenSSH Server service (sshd).

@carlos-vl
Copy link

I am having the same issue, the host is a computer from my company and I cannot do the suggested changes.
Is there any progress on this?

@Mickychen00
Copy link

I have the same issue when I use non Administrator account. But Administrator account is ok.

@grtwje
Copy link

grtwje commented Jun 12, 2022

This issue makes me sad. Since it's "On Deck," I check every new release to see if it's fixed. And it is not.

My workaround is to ssh to bash under WSL2 on the Windows box. The user account does not need administrator for this access method. (Well, I guess you'll need it to install WSL2.)

@burkenyo
Copy link

Hi @grtwje, you can also try some of the above workarounds such as @metablaster’s to connect to the windows side. It does require some mucking around, so an OOB solution build into the extension would be ideal!

@cutec-chris
Copy link

I am having the same issue, the host is a computer from my company and I cannot do the suggested changes. Is there any progress on this?

same here, why this issue has so low priority ?

@Silver-Fang
Copy link

Silver-Fang commented Jun 23, 2022

I am having the same issue, the host is a computer from my company and I cannot do the suggested changes. Is there any progress on this?

same here, why this issue has so low priority ?

Because they believe that very few people will choose Windows instead of Linux as the SSH server, and thus they somewhat don't care about Windows users. They betrayed Microsoft.

@deisi
Copy link

deisi commented Oct 22, 2022

like +1 for this as a fix worthy issue. The workaround from @metablaster works, but changing user permissions might not be possible in a coporate environment, and thats also where windows servers with limited permissions are most likely to occur.

Anyway @roblourens is there any idear how to fix this? I could imagine this is a wontfix as the issue seems to be with how permissions are set within windows by default here.

@tom-inetum-realdolmen
Copy link

Just leaving a message for those coming after me
Root cause is that by default WMI does not allow queries to be executed remotely, which is exactly what you do when you connect to a windows server via WinRM OR via OpenSSH..
To circumvent the issue, you need to grant your nonadmin users the privilege to remotely query wmi, (the root\cimv2 namespace in this scenario but you might also want to enable other namespaces).

  • Open Computer Management -> System Tools -> Local Users and Groups
  • Create a new Local group on the Windows Server/Windows Client (let's call it Remote wmi enabled) and add any accounts in it that must be allowed to query wmi remotely.
  • Open Services and Applications
  • Right click WMI Control and select Properties
  • Go to the Security tab and select the namespace you want to modify (again, root\cimv2 is the bare minimum needed for vscode to work but you might want to allow other namespaces)
  • Add the newly created group to the list and check the option Remote Enable
  • Hit OK a couple of times
  • Make sure all processes of the target user are logged off from the system before retrying: since you add the user to a group it is mandatory in windows to do a complete 'login' again and refresh your group memberships!
  • retry and all should be good

@DanielLaberge
Copy link

DanielLaberge commented Nov 8, 2022

Confirm that metablaster's approach worked for me.

While I understand vs-code cannot do this setup automatically, I believe that when this situation is detected during setup, it should direct users to a help article with official guidance on how to configure this properly with minimal permissions.

Here is slightly different and shorter approach from what @faltrock-abone described: (+1 btw!)

  1. Run compmgmt.msc as Administrator

  2. Select WMI control node -> More actions -> properties

  3. In the Security tab add only the standard user that you'll use for SSH

  4. The rest is same, edit security property for this user:

    • Enable Account and Remote Enable rights \ applies to this namesapce and subnamespaces

What's the difference or why doing it this way? WinRMRemoteWMIUsers__ group is added after you've setup WinRM (not everybody does), this way you skip that part: https://docs.microsoft.com/en-us/windows/win32/winrm/authentication-for-remote-connections

Another difference is that you affect only single standard user account.

edit: Another solution to affect multiple standard users would be to add specific users to Remote management users group, then add this group to WMI. Why? this group has required permissions already set, you only add users to it, and add it to WMI security without additional steps that are needed for single user.

@chhex
Copy link

chhex commented Apr 11, 2023

@tom-inetum-realdolmen Thanks a lot for the detailed guide , which worked for as described, very helpful

@davetapley
Copy link

#2648 (comment) visually 😁

10_1_0_60

@TUstudents
Copy link

Not fixed in VSCode Version: 1.82.2

@Niketin
Copy link

Niketin commented Feb 1, 2024

I'm using VSCode 1.85.1 and I am also facing this problem.

@alexchandel
Copy link

alexchandel commented Feb 15, 2024

#2648 (comment) visually 😁

10_1_0_60

I just wanted to say this is the best documentation I have ever seen.

However, it did not full fix the issue for me. It only changed the error from:

<Objs Version="1.1.0.1"
  xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <S S="Error">gcim : Access denied _x000D__x000A_</S>
  <S S="Error">At line:52 char:6_x000D__x000A_</S>
  <S S="Error">+ $u_=(gcim win32_process | ? processid -eq $t_).parentprocessid_x000D__x000A_</S>
  <S S="Error">+      ~~~~~~~~~~~~~~~~~~_x000D__x000A_</S>
  <S S="Error">    + CategoryInfo          : PermissionDenied: (root\cimv2:win32_process:String) [Get-CimInstance], CimException_x000D__x000A_</S>
  <S S="Error">    + FullyQualifiedErrorId : HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand_x000D__x000A_</S>
  <S S="Error"> _x000D__x000A_</S>
</Objs>

to:

<Objs Version="1.1.0.1"
  xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <S S="Error">gcim : Invalid class _x000D__x000A_</S>
  <S S="Error">At line:52 char:6_x000D__x000A_</S>
  <S S="Error">+ $u_=(gcim win32_process | ? processid -eq $t_).parentprocessid_x000D__x000A_</S>
  <S S="Error">+      ~~~~~~~~~~~~~~~~~~_x000D__x000A_</S>
  <S S="Error">    + CategoryInfo          : MetadataError: (root\cimv2:win32_process:String) [Get-CimInstance], CimException_x000D__x000A_</S>
  <S S="Error">    + FullyQualifiedErrorId : HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand_x000D__x000A_</S>
  <S S="Error"> _x000D__x000A_</S>
</Objs>

\x0D\x0A is CRLF and seems like a red herring, as this is the only reference I can find for x000D__x000A and it's completely irrelevant, meaning this error message is just not decoded correctly.

Restarting sshddid not fix it.

EDIT: restarting the computer was required to finish the fix. Go figure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug plan-review PM-highlighted item determined to be P1 or P2 ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests