Skip to content

Failure in executing Winrm command from remote Ubuntu server 16.04 to remote Windows R2 2012 server #271

Description

@atharva-infiverve

Hi
We are using winrm 2.1.1 with Jruby 9.1.1.0. We are executing some basic powershell commands as well as command-line commands in negotiate as transport mode from a remote Ubuntu server(16.04 LTS) to Windows R2 2012 server were winrm is configured.Below is the code snippet which we are using:

require 'winrm'
opts = {
  endpoint: 'http://someurl.com:5985/wsman',
  transport: :negotiate,
  user: 'Administrator',
  password: 'mypassword'
}
conn = WinRM::Connection.new(opts)
conn.logger.level = :debug
conn.shell(:powershell) do |shell|
  output = shell.run('$PSVersionTable') do |stdout, stderr|
    STDOUT.print stdout
    STDERR.print stderr
  end
  puts "The script exited with exit code #{output.exitcode}"
end

When we are executing the above code we are simply getting connection time out while executing the commands (for both powershell and cmd commands). We are not getting any specific error logs, so we are stuck and unable to debug the root cause.

We have also traced the network packets using Wireshark Tool and we are getting following logs -

Case 1 . Failure in executing command via ubuntu server to Windows server
a. 72.251.240.36 -Ubuntu server
b. 10.0.37.104 Windows R2 2012 server where winrm is configured

winrm-source-destination-failure

Case 2 . Success in executing the command via ubuntu server to Windows server
a. 72.251.240.36 -Ubuntu server
b. 10.0.37.104 Windows R2 2012 server where winrm is configured

winrmrequest-source-destination-success

Please Note: While executing the above code snippet command or any other commands as well , out of 10 times,only 2 times the commands gets executed successfully through the same ubuntu server(72.251.240.36) on the same Windows server(10.0.37.104) .Rest of the time we get a timeout.

Thanks in advance !!
Do let us know if you need any more details.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions