WinRb / WinRM

Ruby library for Windows Remote Management
Apache License 2.0
412 stars 118 forks source link

WinRM ProtocolError #142

Closed sduggisetty closed 9 years ago

sduggisetty commented 9 years ago

Hi,

i am trying to connect a server through the winrm. But getting below error.

Could someone please help me on this. Error: 19:34:52 [overthere-winrm:] failed: WinRM Error: Unexpected HTTP response on http://:5985/wsman: (401) 19:34:52 Failed: WinRMProtocolError: WinRM Error: Unexpected HTTP response on http://:5985/wsman: (401)

Here are the more details for your info:

Server type: Windows 2008 server

winrm config:

C:\Windows\system32>winrm get winrm/config Config MaxEnvelopeSizekb = 150 MaxTimeoutms = 900000 MaxBatchItems = 32000 MaxProviderRequests = 4294967295 Client NetworkDelayms = 5000 URLPrefix = wsman AllowUnencrypted = false 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 IdleTimeout = 180000 MaxConcurrentUsers = 5 MaxShellRunTime = 2147483647 MaxProcessesPerShell = 15 MaxMemoryPerShellMB = 1024 MaxShellsPerUser = 5

mwrock commented 9 years ago

Looks like the host is not being parsed correctly or is just not passed. Note the url in the error:

http://:5985/wsman

This could probably stand better error handling but I would review how you are passing the host name.

sduggisetty commented 9 years ago

@mwrock

I have removed the ip address.

parsing as below. http://:5985/wsman

mwrock commented 9 years ago

Heh. ok. Well the other thing that stands out to me is the (401) which indicates an auth issue. Is the winrm endpoint domain joined and do you mind sharing how you are initializing the WinRMWebService?

sduggisetty commented 9 years ago

I am trying to run a small command through rundeck job.

while executing rundeck job, getting below error. I am passing user id and password to the rundeck job.

[overthere-winrm:] failed: WinRM Error: Unexpected HTTP response on http://:5985/wsman: (401) 21:48:45 Failed: WinRMProtocolError: WinRM Error: Unexpected HTTP response on http://:5985/wsman: (401) 21:48:45 .activehealt.loc Execution failed: 4780: [Workflow step failures: {1=Dispatch failed on 1 nodes: [: WinRMProtocolError: WinRM Error: Unexpected HTTP response on http://:5985/wsman: (401)]}, Node failures: {=[WinRMProtocolError: WinRM Error: Unexpected HTTP response on http://:5985/wsman: (401)]}]

zenchild commented 9 years ago

Can you show the code for the WinRMWebService instantiation?

zenchild commented 9 years ago

... or if Rundeck is doing the instantiation. Take that out of the picture and trying running WinRM by itself so we can get to the root of the issue.

sduggisetty commented 9 years ago

@zenchild Apologies. i am very new to winrm. if you dont mind, could you please get me the command which can get you the input for you..

my rundeck is installed in linux box. i am trying to connect windows server through winrm from the rundeck. Able to connect few machines, but not this machine. :-(

Thanks a lot for your help in advance.

-Subbu

zenchild commented 9 years ago

Have a look at the README for the gem. How you instantiate it depends on your authentication mechanism. I imagine you're probably just using Basic/plaintext so have a look at that example.

https://github.com/WinRb/WinRM/blob/master/README.md

zenchild commented 9 years ago

I just noticed this, since I'm not that familiar with Rundeck but it appears to be using the Java library from XebiaLabs and not the WinRM Ruby gem.

sduggisetty commented 9 years ago

Yes; it appears like java issue.

error: com.xebialabs.overthere.cifs.winrm.WinRmRuntimeIOException: Unexpected HTTP response on http://172.20.18.196:5985/wsman: (401) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient.doSendRequest(WinRmClient.java:422) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient.access$100(WinRmClient.java:105) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient$PrivilegedSendMessage.run(WinRmClient.java:389) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient$PrivilegedSendMessage.run(WinRmClient.java:378) 14:12:16 at java.security.AccessController.doPrivileged(Native Method) 14:12:16 at javax.security.auth.Subject.doAs(Subject.java:416) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient.runPrivileged(WinRmClient.java:364) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient.sendRequest(WinRmClient.java:348) 14:12:16 at com.xebialabs.overthere.cifs.winrm.WinRmClient.createShell(WinRmClient.java:158) 14:12:16 at com.xebialabs.overthere.cifs.winrm.CifsWinRmConnection.startProcess(CifsWinRmConnection.java:114) 14:12:16 at com.xebialabs.overthere.spi.BaseOverthereConnection.execute(BaseOverthereConnection.java:261) 14:12:16 at com.dtolabs.rundeck.plugin.overthere.OTWinRMNodeExecutor.executeCommand(OTWinRMNodeExecutor.java:197) 14:12:16 at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.executeCommand(ExecutionServiceImpl.java:333) 14:12:16 at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.executeCommand(ExecutionServiceImpl.java:307) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.steps.node.impl.ExecNodeStepExecutor.executeNodeStep(ExecNodeStepExecutor.java:53) 14:12:16 at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.executeNodeStep(ExecutionServiceImpl.java:149) 14:12:16 at com.dtolabs.rundeck.core.execution.dispatch.SequentialNodeDispatcher.dispatch(SequentialNodeDispatcher.java:116) 14:12:16 at com.dtolabs.rundeck.core.execution.dispatch.SequentialNodeDispatcher.dispatch(SequentialNodeDispatcher.java:58) 14:12:16 at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.dispatchToNodes(ExecutionServiceImpl.java:177) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.steps.NodeDispatchStepExecutor.executeWorkflowStep(NodeDispatchStepExecutor.java:66) 14:12:16 at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.executeStep(ExecutionServiceImpl.java:116) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.BaseWorkflowStrategy.executeWFItem(BaseWorkflowStrategy.java:162) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.BaseWorkflowStrategy.executeWorkflowItemsForNodeSet(BaseWorkflowStrategy.java:222) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.BaseWorkflowStrategy.executeWorkflowItemsForNodeSet(BaseWorkflowStrategy.java:189) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.StepFirstWorkflowStrategy.executeWorkflowImpl(StepFirstWorkflowStrategy.java:79) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.BaseWorkflowStrategy.executeWorkflow(BaseWorkflowStrategy.java:120) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.NodeFirstWorkflowStrategy$DispatchedWorkflow.dispatch(NodeFirstWorkflowStrategy.java:365) 14:12:16 at com.dtolabs.rundeck.core.execution.dispatch.SequentialNodeDispatcher.dispatch(SequentialNodeDispatcher.java:118) 14:12:16 at com.dtolabs.rundeck.core.execution.dispatch.SequentialNodeDispatcher.dispatch(SequentialNodeDispatcher.java:64) 14:12:16 at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.dispatchToNodes(ExecutionServiceImpl.java:196) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.NodeFirstWorkflowStrategy.executeWFSectionNodeDispatch(NodeFirstWorkflowStrategy.java:177) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.NodeFirstWorkflowStrategy.executeWorkflowImpl(NodeFirstWorkflowStrategy.java:106) 14:12:16 at com.dtolabs.rundeck.core.execution.workflow.BaseWorkflowStrategy.executeWorkflow(BaseWorkflowStrategy.java:120) 14:12:16 at com.dtolabs.rundeck.core.execution.WorkflowExecutionServiceThread.run(WorkflowExecutionServiceThread.java:55)

sduggisetty commented 9 years ago

am still unable to connect. getting same error.

Please help..

zenchild commented 9 years ago

@sduggisetty Rundeck is not using this gem. It is using the Java library found here: https://github.com/xebialabs/overthere.

sduggisetty commented 9 years ago

oh okay. so i need to raise issue in this group.