【问题标题】:Chef/Ruby: Bad HTTP response returned from server (401). (WinRM::WinRMHTTPTransportError)Ruby:Chef/Ruby:服务器返回错误的 HTTP 响应 (401)。 (WinRM::WinRMHTTPTransportError)Ruby:
【发布时间】:2013-12-03 19:40:37
【问题描述】:

注意:我正在使用 Active Directory 身份验证 - 无法解决此问题。

我正在尝试使用以下脚本:

require 'winrm'

IP=ARGV[0]
USER=ARGV[1]
endpoint = "http://#{IP}:5985/wsman"
winrm = WinRM::WinRMWebService.new endpoint, :plaintext, user: USER, pass: 'secret', basic_auth_only: true
winrm.set_timeout 1800

installer_file = "c:\\Users\\#{USER}\\Downloads\\chef_client.msi"
installer_cmd = "msiexec /qn /i #{installer_file} ADDLOCAL=\"ChefServiceFeature,ChefClientFeature\""

puts 'Installating Chef'
puts installer_cmd
install_output = winrm.cmd installer_cmd

sleep 300
puts 'Configuring Chef'
winrm.cmd %Q(mv c:\\Users\\#{USER}\\Downloads\\client.rb c:\\chef\\client.rb)
winrm.cmd %Q(mv c:\\Users\\#{USER}\\Downloads\\chef-validator.pem c:\\chef\\validation.pem)
winrm.cmd 'net start chef-client || net start chef-client'

当我这样做时:ruby chef_windows_boostrap.rb test168.domain.com ctote,我得到以下输出:

c:\opscode\chef>ruby chef_windows_boostrap.rb test168.domain.com ctote
Installating Chef
msiexec /qn /i c:\Users\ctote\Downloads\chef_client.msi ADDLOCAL="ChefServiceFeature,ChefClientFeature"
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/winrm-1.1.3/lib/winrm/http/transport.rb:48:in `send_request': Bad HTTP response returned from server (401). (WinRM::WinRMHTTPTransportError)
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/winrm-1.1.3/lib/winrm/winrm_service.rb:368:in `send_message'
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/winrm-1.1.3/lib/winrm/winrm_service.rb:113:in `open_shell'
        from C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/winrm-1.1.3/lib/winrm/winrm_service.rb:239:in `run_cmd'
        from chef_windows_boostrap.rb:14:in `<main>'

以下是我的 winrm 配置设置:

c:\opscode\chef>winrm get winrm/config
Config
    MaxEnvelopeSizekb = 150
    MaxTimeoutms = 1800000
    MaxBatchItems = 32000
    MaxProviderRequests = 4294967295
    Client
        NetworkDelayms = 5000
        URLPrefix = wsman
        AllowUnencrypted = true
        Auth
            Basic = true
            Digest = true
            Kerberos = true
            Negotiate = true
            Certificate = true
            CredSSP = false
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        TrustedHosts
    Service
        RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)
        MaxConcurrentOperations = 4294967295
        MaxConcurrentOperationsPerUser = 15
        EnumerationTimeoutms = 60000
        MaxConnections = 25
        MaxPacketRetrievalTimeSeconds = 120
        AllowUnencrypted = true
        Auth
            Basic = true
            Kerberos = true
            Negotiate = true
            Certificate = false
            CredSSP = false
            CbtHardeningLevel = Relaxed
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        IPv4Filter = *
        IPv6Filter = *
        EnableCompatibilityHttpListener = false
        EnableCompatibilityHttpsListener = false
        CertificateThumbprint
    Winrs
        AllowRemoteShellAccess = true [Source="GPO"]
        IdleTimeout = 180000
        MaxConcurrentUsers = 5
        MaxShellRunTime = 2147483647
        MaxProcessesPerShell = 15
        MaxMemoryPerShellMB = 300
        MaxShellsPerUser = 5

在这一点上,我不知道该尝试什么 - 有人有什么建议吗?有没有办法可以通过wireshark来帮助调试或其他什么?

【问题讨论】:

标签: ruby chef-infra winrm


【解决方案1】:

以下脚本必须在 Windows 服务器上运行。

winrm set winrm/config/client/auth @{Basic="true"}
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}

来源:http://talk.manageiq.org/t/steps-to-join-hyper-v-vmm-to-manageiq/151

【讨论】:

  • 如果你从 powershell 运行,你会得到错误:'命令行的使用无效'。您必须从 'cmd' 运行它
猜你喜欢
  • 1970-01-01
  • 2012-07-02
  • 1970-01-01
  • 2012-05-15
  • 2015-12-13
  • 2018-02-13
  • 1970-01-01
  • 2014-03-14
  • 2012-03-10
相关资源
最近更新 更多