代码之家  ›  专栏  ›  技术社区  ›  ca9163d9

invoke sqlcmd在进入pssession后出现“nt authority\anonymous logon”错误?

  •  0
  • ca9163d9  · 技术社区  · 6 年前

    我在上运行了以下查询 RemoteServer 之后 enter-pssesion 从我的电脑 ClientPC . (我需要使用Windows集成安全性)

    Enter-PSSesion RemoteServer # from ClientPC
    Invoke-Sqlcmd -ServerInstance sqlserver 'select 1 a' # in the ps session of RemoteServer
    

    它的错误是

    invoke sqlcmd:用户“nt authority\anonymous logon”登录失败。

    然后我做了以下步骤。

    远程服务器 ,

    Enable-WSManCredSSP -Role server
    

    它回来了

    CredSSP Authentication Configuration for WS-Management
    CredSSP authentication allows the server to accept user credentials from a remote computer. If you enable CredSSP
    authentication on the server, the server will have access to the user name and password of the client computer if the
    client computer sends them. For more information, see the Enable-WSManCredSSP Help topic.
    Do you want to enable CredSSP authentication?
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):
    
    
    cfg               : http://schemas.microsoft.com/wbem/wsman/1/config/service/auth
    lang              : en-US
    Basic             : false
    Kerberos          : true
    Negotiate         : true
    Certificate       : false
    CredSSP           : true
    CbtHardeningLevel : Relaxed
    

    在我的电脑上 客户PC .

    PS C:\> Enable-WSManCredSSP -Role client -DelegateComputer *
    
    CredSSP Authentication Configuration for WS-Management
    CredSSP authentication allows the user credentials on this computer to be sent to a remote computer. If you use CredSSP
     authentication for a connection to a malicious or compromised computer, that computer will have access to your user
    name and password. For more information, see the Enable-WSManCredSSP Help topic.
    Do you want to enable CredSSP authentication?
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):
    
    
    cfg         : http://schemas.microsoft.com/wbem/wsman/1/config/client/auth
    lang        : en-US
    Basic       : true
    Digest      : true
    Kerberos    : true
    Negotiate   : true
    Certificate : true
    CredSSP     : true
    

    但我还是搞错了?

    1 回复  |  直到 6 年前
        1
  •  2
  •   HAL9256    6 年前

    如果在客户机和服务器上都启用了CredSSP(对于此双跃点身份验证是必需的),则只需将身份验证显式指定为CredSSP,因为默认情况下它不会与之连接。

    Enter-PSSession RemoteServer -Authentication Credssp -Credential (Get-Credential)