Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Example code fails with httpclient/auth.rb:564:in `get': undefined method `init_context' for nil:NilClass (NoMethodError) #34

Closed
pkolmann opened this Issue Dec 27, 2012 · 4 comments

Comments

Projects
None yet
4 participants

Hi,

I am new to ruby and WinRM on linux but I would like to use it. I installed the required gems on a Debian unstable box and now I am trying to run the example script against a test environment:

!/usr/bin/ruby

require 'winrm'
endpoint = 'http://dc01.DOMAIN.tuwien.ac.at:5985/wsman'
winrm = WinRM::WinRMWebService.new(endpoint, :plaintext, :user => 'DOMAIN\Administrator', :pass => 'PASSWORD')
winrm.cmd('ipconfig /all') do |stdout, stderr|
STDOUT.print stdout
STDERR.print stderr
end

On the windows box I see winrshost.exe and conhost.exe beeing spawned but on linux I get the following output:

./ex1.rb
/var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient/auth.rb:564:in get': undefined methodinit_context' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient/auth.rb:114:in block in filter_request' from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient/auth.rb:112:ineach'
from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient/auth.rb:112:in filter_request' from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:1047:inblock in do_get_block'
from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:1046:in each' from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:1046:indo_get_block'
from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:866:in block in do_request' from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:953:inprotect_keep_alive_disconnected'
from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:865:in do_request' from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:753:inrequest'
from /var/lib/gems/1.9.1/gems/httpclient-2.2.0.2/lib/httpclient.rb:663:in post' from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/http/transport.rb:38:insend_request'
from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/winrm_service.rb:368:in send_message' from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/winrm_service.rb:136:inrun_command'
from /var/lib/gems/1.9.1/gems/winrm-1.1.2/lib/winrm/winrm_service.rb:240:in run_cmd' from ./ex1.rb:9:in

'

Do you have any idea, what I have done wrong?
I have enabled UnecryptedTransport and Basic Auth.

Thanks
Philipp

jdub commented Mar 8, 2013

Getting the same thing. Ubuntu, Ruby 1.9.3-p125, winrm dependencies built and installed, very much the same test script and configuration vs. Windows 2012 Core.

I'm being bitten by this error as well. Using an OS X machine to talk to a Windows 2008 R2 machine. Haven't been able to figure out how to fix or work around it yet. @zenchild any suggestions?

edit: I added the :basic_auth_only => true option to my instance of WinRM::WinRMWebService and it worked. @jdub and @pkolmann

Contributor

pmorton commented Mar 22, 2013

I was just searching for this fix :basic_auth_only => true. What this does is turn off GSSAPI authentication in the HTTP client. What is happening is that the httpclient sees that GSSAPI gem is installed and tries to use it. If you are on a machine that does not have a full kerberos environment (or one at all), httpclient still tries to use kerberos even though your environment is not complete.

I am working on a major update to the WinRM gem and some of the underlying libraries. In specific, I am in the process of fixing up the rubyntlm gem so that authentication works seamlessly out of the box with the winrm gem.

Contributor

pmorton commented Mar 22, 2013

You can also specify :disable_sspi => true to turn off kerberos only. Please re-open this bug either of these do not resolve your issue.

@pmorton pmorton closed this Mar 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment