winrm 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +10 -10
- data/.rspec +3 -3
- data/.rubocop.yml +12 -12
- data/.travis.yml +12 -12
- data/Gemfile +9 -9
- data/LICENSE +202 -202
- data/README.md +194 -194
- data/Rakefile +36 -36
- data/Vagrantfile +9 -9
- data/appveyor.yml +42 -42
- data/bin/rwinrm +97 -97
- data/changelog.md +74 -71
- data/lib/winrm.rb +42 -42
- data/lib/winrm/command_executor.rb +224 -224
- data/lib/winrm/exceptions/exceptions.rb +57 -57
- data/lib/winrm/helpers/iso8601_duration.rb +58 -58
- data/lib/winrm/helpers/powershell_script.rb +42 -42
- data/lib/winrm/http/response_handler.rb +82 -82
- data/lib/winrm/http/transport.rb +421 -421
- data/lib/winrm/output.rb +43 -43
- data/lib/winrm/soap_provider.rb +39 -39
- data/lib/winrm/version.rb +7 -7
- data/lib/winrm/winrm_service.rb +556 -556
- data/preamble +17 -17
- data/spec/auth_timeout_spec.rb +16 -16
- data/spec/cmd_spec.rb +102 -102
- data/spec/command_executor_spec.rb +429 -429
- data/spec/config-example.yml +19 -19
- data/spec/exception_spec.rb +50 -50
- data/spec/issue_184_spec.rb +67 -67
- data/spec/issue_59_spec.rb +23 -23
- data/spec/matchers.rb +74 -74
- data/spec/output_spec.rb +110 -110
- data/spec/powershell_spec.rb +97 -97
- data/spec/response_handler_spec.rb +59 -59
- data/spec/spec_helper.rb +73 -73
- data/spec/stubs/responses/get_command_output_response.xml.erb +13 -13
- data/spec/stubs/responses/open_shell_v1.xml +19 -19
- data/spec/stubs/responses/open_shell_v2.xml +20 -20
- data/spec/stubs/responses/soap_fault_v1.xml +36 -36
- data/spec/stubs/responses/soap_fault_v2.xml +42 -42
- data/spec/stubs/responses/wmi_error_v2.xml +41 -41
- data/spec/transport_spec.rb +124 -124
- data/spec/winrm_options_spec.rb +76 -76
- data/spec/winrm_primitives_spec.rb +51 -51
- data/spec/wql_spec.rb +14 -14
- data/winrm.gemspec +40 -40
- metadata +2 -2
data/README.md
CHANGED
@@ -1,194 +1,194 @@
|
|
1
|
-
# Windows Remote Management (WinRM) for Ruby
|
2
|
-
[](https://travis-ci.org/WinRb/WinRM)
|
3
|
-
[](http://badge.fury.io/rb/winrm)
|
4
|
-
[](https://ci.appveyor.com/project/winrb/winrm)
|
5
|
-
|
6
|
-
This is a SOAP library that uses the functionality in Windows Remote
|
7
|
-
Management(WinRM) to call native object in Windows. This includes, but is
|
8
|
-
not limitted to, running batch scripts, powershell scripts and fetching WMI
|
9
|
-
variables. For more information on WinRM, please visit Microsoft's WinRM
|
10
|
-
site: http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx
|
11
|
-
|
12
|
-
## Supported WinRM Versions
|
13
|
-
WinRM 1.1 is supported, however 2.0 and higher is recommended. [See MSDN](http://technet.microsoft.com/en-us/library/ff520073(v=ws.10).aspx) for information about WinRM versions and supported operating systems.
|
14
|
-
|
15
|
-
## Install
|
16
|
-
`gem install -r winrm` then on the server `winrm quickconfig` as admin
|
17
|
-
|
18
|
-
## Example
|
19
|
-
```ruby
|
20
|
-
require 'winrm'
|
21
|
-
endpoint = 'http://mywinrmhost:5985/wsman'
|
22
|
-
krb5_realm = 'EXAMPLE.COM'
|
23
|
-
winrm = WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => krb5_realm)
|
24
|
-
winrm.create_executor do |executor|
|
25
|
-
executor.run_cmd('ipconfig /all') do |stdout, stderr|
|
26
|
-
STDOUT.print stdout
|
27
|
-
STDERR.print stderr
|
28
|
-
end
|
29
|
-
end
|
30
|
-
```
|
31
|
-
|
32
|
-
There are various connection types you can specify upon initialization:
|
33
|
-
|
34
|
-
It is recommended that you <code>:disable_sspi => true</code> if you are using the plaintext or ssl transport.
|
35
|
-
|
36
|
-
### Deprecated methods
|
37
|
-
As of version 1.5.0 `WinRM::WinRMWebService` methods `cmd`, `run_cmd`, `powershell`, and `run_powershell_script` have been deprecated and will be removed from the next major version of the WinRM gem.
|
38
|
-
|
39
|
-
Use the `run_cmd` and `run_powershell_script` of the `WinRM::CommandExecutor` class instead. The `CommandExecutor` allows multiple commands to be run from the same WinRM shell providing a significant performance improvement when issuing multiple calls.
|
40
|
-
|
41
|
-
#### NTLM/Negotiate
|
42
|
-
```ruby
|
43
|
-
winrm = WinRM::WinRMWebService.new(endpoint, :negotiate, :user => myuser, :pass => mypass)
|
44
|
-
```
|
45
|
-
|
46
|
-
#### Plaintext
|
47
|
-
Note: It is strongly recommended that you use `:negotiate` instead of `:plaintext`. As the name infers, the `:plaintext` transport includes authentication credentials in plain text.
|
48
|
-
```ruby
|
49
|
-
WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :disable_sspi => true)
|
50
|
-
|
51
|
-
## Same but force basic authentication:
|
52
|
-
WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :basic_auth_only => true)
|
53
|
-
```
|
54
|
-
|
55
|
-
#### SSL
|
56
|
-
```ruby
|
57
|
-
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :disable_sspi => true)
|
58
|
-
|
59
|
-
# Specifying CA path
|
60
|
-
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :ca_trust_path => '/etc/ssl/certs/cert.pem', :basic_auth_only => true)
|
61
|
-
|
62
|
-
# Same but force basic authentication:
|
63
|
-
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true)
|
64
|
-
|
65
|
-
# Basic auth over SSL w/self signed cert
|
66
|
-
# Enabling no_ssl_peer_verification is not recommended. HTTPS connections are still encrypted,
|
67
|
-
# but the WinRM gem is not able to detect forged replies or man in the middle attacks.
|
68
|
-
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true, :no_ssl_peer_verification => true)
|
69
|
-
|
70
|
-
# Verify against a known fingerprint
|
71
|
-
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true, :ssl_peer_fingerprint => '6C04B1A997BA19454B0CD31C65D7020A6FC2669D')
|
72
|
-
```
|
73
|
-
|
74
|
-
##### Create a self signed cert for WinRM
|
75
|
-
You may want to create a self signed certificate for servicing https WinRM connections. You can use the following PowerShell script to create a cert and enable the WinRM HTTPS listener. Unless you are running windows server 2012 R2 or later, you must install makecert.exe from the Windows SDK, otherwise use `New-SelfSignedCertificate`.
|
76
|
-
|
77
|
-
```powershell
|
78
|
-
$hostname = $Env:ComputerName
|
79
|
-
|
80
|
-
C:\"Program Files"\"Microsoft SDKs"\Windows\v7.1\Bin\makecert.exe -r -pe -n "CN=$hostname,O=vagrant" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 "$hostname.cer"
|
81
|
-
|
82
|
-
$thumbprint = (& ls cert:LocalMachine/my).Thumbprint
|
83
|
-
|
84
|
-
# Windows 2012R2 and above can use New-SelfSignedCertificate
|
85
|
-
$thumbprint = (New-SelfSignedCertificate -DnsName $hostname -CertStoreLocation cert:\LocalMachine\my).Thumbprint
|
86
|
-
|
87
|
-
$cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"$hostname`";CertificateThumbprint=`"$thumbprint`"}'"
|
88
|
-
iex $cmd
|
89
|
-
```
|
90
|
-
|
91
|
-
#### Kerberos
|
92
|
-
```ruby
|
93
|
-
WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => 'MYREALM.COM')
|
94
|
-
```
|
95
|
-
|
96
|
-
## Retries and opening a shell
|
97
|
-
Especially if provisioning a new machine, it's possible the winrm service is not yet running when first attempting to connect. The `WinRMWebService` accepts the options `:retry_limit` and `:retry_delay` to specify the maximum number of attempts to make and how long to wait in between. These default to 3 attempts and a 10 second delay.
|
98
|
-
```ruby
|
99
|
-
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :retry_limit => 30, :retry_delay => 10)
|
100
|
-
```
|
101
|
-
|
102
|
-
## Logging
|
103
|
-
The `WinRMWebService` exposes a `logger` attribute and uses the [logging](https://rubygems.org/gems/logging) gem to manage logging behavior. By default this appends to `STDOUT` and has a level of `:warn`, but one can adjust the level or add additional appenders.
|
104
|
-
```ruby
|
105
|
-
winrm = WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass)
|
106
|
-
|
107
|
-
# suppress warnings
|
108
|
-
winrm.logger.level = :error
|
109
|
-
|
110
|
-
# Log to a file
|
111
|
-
winrm.logger.add_appenders(Logging.appenders.file('error.log'))
|
112
|
-
```
|
113
|
-
|
114
|
-
If a consuming application uses its own logger that complies to the logging API, you can simply swap it in:
|
115
|
-
```ruby
|
116
|
-
winrm.logger = my_logger
|
117
|
-
```
|
118
|
-
|
119
|
-
## Troubleshooting
|
120
|
-
You may have some errors like ```WinRM::WinRMAuthorizationError```.
|
121
|
-
You can run the following commands on the server to try to solve the problem:
|
122
|
-
```
|
123
|
-
winrm set winrm/config/client/auth @{Basic="true"}
|
124
|
-
winrm set winrm/config/service/auth @{Basic="true"}
|
125
|
-
winrm set winrm/config/service @{AllowUnencrypted="true"}
|
126
|
-
```
|
127
|
-
You can read more about that on issue [#29](https://github.com/WinRb/WinRM/issues/29)
|
128
|
-
|
129
|
-
Also see [this post](http://www.hurryupandwait.io/blog/understanding-and-troubleshooting-winrm-connection-and-authentication-a-thrill-seekers-guide-to-adventure) for more general tips related to winrm connection and authentication issues.
|
130
|
-
|
131
|
-
|
132
|
-
## Current features
|
133
|
-
|
134
|
-
1. GSSAPI support: This is the default way that Windows authenticates and
|
135
|
-
secures WinRM messages. In order for this to work the computer you are
|
136
|
-
connecting to must be a part of an Active Directory domain and you must
|
137
|
-
have local credentials via kinit. GSSAPI support is dependent on the
|
138
|
-
gssapi gem which only supports the MIT Kerberos libraries at this time.
|
139
|
-
|
140
|
-
If you are using this method there is no longer a need to change the
|
141
|
-
WinRM service authentication settings. You can simply do a
|
142
|
-
'winrm quickconfig' on your server or enable WinRM via group policy and
|
143
|
-
everything should be working.
|
144
|
-
|
145
|
-
2. Multi-Instance support: Moving away from Handsoap allows multiple
|
146
|
-
instances to be created because the SOAP backend is no longer a Singleton
|
147
|
-
type class.
|
148
|
-
|
149
|
-
3. 100% Ruby: Nokogiri while faster can present additional frustration for
|
150
|
-
users above and beyond what is already required to get WinRM working.
|
151
|
-
The goal of this gem is make using WinRM easy. In V2 we plan on making
|
152
|
-
the parser swappable in case you really do need the performance.
|
153
|
-
|
154
|
-
## Contributing
|
155
|
-
|
156
|
-
1. Fork it.
|
157
|
-
2. Create a branch (git checkout -b my_feature_branch)
|
158
|
-
3. Run the unit and integration tests (bundle exec rake integration)
|
159
|
-
4. Commit your changes (git commit -am "Added a sweet feature")
|
160
|
-
5. Push to the branch (git push origin my_feature_branch)
|
161
|
-
6. Create a pull requst from your branch into master (Please be sure to provide enough detail for us to cipher what this change is doing)
|
162
|
-
|
163
|
-
### Running the tests
|
164
|
-
|
165
|
-
We use Bundler to manage dependencies during development.
|
166
|
-
|
167
|
-
```
|
168
|
-
$ bundle install
|
169
|
-
```
|
170
|
-
|
171
|
-
Once you have the dependencies, you can run the unit tests with `rake`:
|
172
|
-
|
173
|
-
```
|
174
|
-
$ bundle exec rake spec
|
175
|
-
```
|
176
|
-
|
177
|
-
To run the integration tests you will need a Windows box with the WinRM service properly configured. Its easiest to use a Vagrant Windows box (mwrock/Windows2012R2 is public on [atlas](https://atlas.hashicorp.com/mwrock/boxes/Windows2012R2) with an evaluation version of Windows 2012 R2).
|
178
|
-
|
179
|
-
1. Create a Windows VM with WinRM configured (see above).
|
180
|
-
2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
|
181
|
-
3. Ensure that the box you are running the test against has a default shell profile (check ~\Documents\WindowsPowerShell). If any of your shell profiles generate stdout or stderr output, the test validators may get thrown off.
|
182
|
-
4. Run `bundle exec rake integration`
|
183
|
-
|
184
|
-
## WinRM Author
|
185
|
-
* Twitter: [@zentourist](https://twitter.com/zentourist)
|
186
|
-
* BLOG: [http://distributed-frostbite.blogspot.com/](http://distributed-frostbite.blogspot.com/)
|
187
|
-
* Add me in LinkedIn: [http://www.linkedin.com/in/danwanek](http://www.linkedin.com/in/danwanek)
|
188
|
-
* Find me on irc.freenode.net in #ruby-lang (zenChild)
|
189
|
-
|
190
|
-
## Maintainers
|
191
|
-
* Paul Morton (https://github.com/pmorton)
|
192
|
-
* Shawn Neal (https://github.com/sneal)
|
193
|
-
|
194
|
-
[Contributors](https://github.com/WinRb/WinRM/graphs/contributors)
|
1
|
+
# Windows Remote Management (WinRM) for Ruby
|
2
|
+
[](https://travis-ci.org/WinRb/WinRM)
|
3
|
+
[](http://badge.fury.io/rb/winrm)
|
4
|
+
[](https://ci.appveyor.com/project/winrb/winrm)
|
5
|
+
|
6
|
+
This is a SOAP library that uses the functionality in Windows Remote
|
7
|
+
Management(WinRM) to call native object in Windows. This includes, but is
|
8
|
+
not limitted to, running batch scripts, powershell scripts and fetching WMI
|
9
|
+
variables. For more information on WinRM, please visit Microsoft's WinRM
|
10
|
+
site: http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx
|
11
|
+
|
12
|
+
## Supported WinRM Versions
|
13
|
+
WinRM 1.1 is supported, however 2.0 and higher is recommended. [See MSDN](http://technet.microsoft.com/en-us/library/ff520073(v=ws.10).aspx) for information about WinRM versions and supported operating systems.
|
14
|
+
|
15
|
+
## Install
|
16
|
+
`gem install -r winrm` then on the server `winrm quickconfig` as admin
|
17
|
+
|
18
|
+
## Example
|
19
|
+
```ruby
|
20
|
+
require 'winrm'
|
21
|
+
endpoint = 'http://mywinrmhost:5985/wsman'
|
22
|
+
krb5_realm = 'EXAMPLE.COM'
|
23
|
+
winrm = WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => krb5_realm)
|
24
|
+
winrm.create_executor do |executor|
|
25
|
+
executor.run_cmd('ipconfig /all') do |stdout, stderr|
|
26
|
+
STDOUT.print stdout
|
27
|
+
STDERR.print stderr
|
28
|
+
end
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
There are various connection types you can specify upon initialization:
|
33
|
+
|
34
|
+
It is recommended that you <code>:disable_sspi => true</code> if you are using the plaintext or ssl transport.
|
35
|
+
|
36
|
+
### Deprecated methods
|
37
|
+
As of version 1.5.0 `WinRM::WinRMWebService` methods `cmd`, `run_cmd`, `powershell`, and `run_powershell_script` have been deprecated and will be removed from the next major version of the WinRM gem.
|
38
|
+
|
39
|
+
Use the `run_cmd` and `run_powershell_script` of the `WinRM::CommandExecutor` class instead. The `CommandExecutor` allows multiple commands to be run from the same WinRM shell providing a significant performance improvement when issuing multiple calls.
|
40
|
+
|
41
|
+
#### NTLM/Negotiate
|
42
|
+
```ruby
|
43
|
+
winrm = WinRM::WinRMWebService.new(endpoint, :negotiate, :user => myuser, :pass => mypass)
|
44
|
+
```
|
45
|
+
|
46
|
+
#### Plaintext
|
47
|
+
Note: It is strongly recommended that you use `:negotiate` instead of `:plaintext`. As the name infers, the `:plaintext` transport includes authentication credentials in plain text.
|
48
|
+
```ruby
|
49
|
+
WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :disable_sspi => true)
|
50
|
+
|
51
|
+
## Same but force basic authentication:
|
52
|
+
WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :basic_auth_only => true)
|
53
|
+
```
|
54
|
+
|
55
|
+
#### SSL
|
56
|
+
```ruby
|
57
|
+
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :disable_sspi => true)
|
58
|
+
|
59
|
+
# Specifying CA path
|
60
|
+
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :ca_trust_path => '/etc/ssl/certs/cert.pem', :basic_auth_only => true)
|
61
|
+
|
62
|
+
# Same but force basic authentication:
|
63
|
+
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true)
|
64
|
+
|
65
|
+
# Basic auth over SSL w/self signed cert
|
66
|
+
# Enabling no_ssl_peer_verification is not recommended. HTTPS connections are still encrypted,
|
67
|
+
# but the WinRM gem is not able to detect forged replies or man in the middle attacks.
|
68
|
+
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true, :no_ssl_peer_verification => true)
|
69
|
+
|
70
|
+
# Verify against a known fingerprint
|
71
|
+
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true, :ssl_peer_fingerprint => '6C04B1A997BA19454B0CD31C65D7020A6FC2669D')
|
72
|
+
```
|
73
|
+
|
74
|
+
##### Create a self signed cert for WinRM
|
75
|
+
You may want to create a self signed certificate for servicing https WinRM connections. You can use the following PowerShell script to create a cert and enable the WinRM HTTPS listener. Unless you are running windows server 2012 R2 or later, you must install makecert.exe from the Windows SDK, otherwise use `New-SelfSignedCertificate`.
|
76
|
+
|
77
|
+
```powershell
|
78
|
+
$hostname = $Env:ComputerName
|
79
|
+
|
80
|
+
C:\"Program Files"\"Microsoft SDKs"\Windows\v7.1\Bin\makecert.exe -r -pe -n "CN=$hostname,O=vagrant" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 "$hostname.cer"
|
81
|
+
|
82
|
+
$thumbprint = (& ls cert:LocalMachine/my).Thumbprint
|
83
|
+
|
84
|
+
# Windows 2012R2 and above can use New-SelfSignedCertificate
|
85
|
+
$thumbprint = (New-SelfSignedCertificate -DnsName $hostname -CertStoreLocation cert:\LocalMachine\my).Thumbprint
|
86
|
+
|
87
|
+
$cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"$hostname`";CertificateThumbprint=`"$thumbprint`"}'"
|
88
|
+
iex $cmd
|
89
|
+
```
|
90
|
+
|
91
|
+
#### Kerberos
|
92
|
+
```ruby
|
93
|
+
WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => 'MYREALM.COM')
|
94
|
+
```
|
95
|
+
|
96
|
+
## Retries and opening a shell
|
97
|
+
Especially if provisioning a new machine, it's possible the winrm service is not yet running when first attempting to connect. The `WinRMWebService` accepts the options `:retry_limit` and `:retry_delay` to specify the maximum number of attempts to make and how long to wait in between. These default to 3 attempts and a 10 second delay.
|
98
|
+
```ruby
|
99
|
+
WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :retry_limit => 30, :retry_delay => 10)
|
100
|
+
```
|
101
|
+
|
102
|
+
## Logging
|
103
|
+
The `WinRMWebService` exposes a `logger` attribute and uses the [logging](https://rubygems.org/gems/logging) gem to manage logging behavior. By default this appends to `STDOUT` and has a level of `:warn`, but one can adjust the level or add additional appenders.
|
104
|
+
```ruby
|
105
|
+
winrm = WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass)
|
106
|
+
|
107
|
+
# suppress warnings
|
108
|
+
winrm.logger.level = :error
|
109
|
+
|
110
|
+
# Log to a file
|
111
|
+
winrm.logger.add_appenders(Logging.appenders.file('error.log'))
|
112
|
+
```
|
113
|
+
|
114
|
+
If a consuming application uses its own logger that complies to the logging API, you can simply swap it in:
|
115
|
+
```ruby
|
116
|
+
winrm.logger = my_logger
|
117
|
+
```
|
118
|
+
|
119
|
+
## Troubleshooting
|
120
|
+
You may have some errors like ```WinRM::WinRMAuthorizationError```.
|
121
|
+
You can run the following commands on the server to try to solve the problem:
|
122
|
+
```
|
123
|
+
winrm set winrm/config/client/auth @{Basic="true"}
|
124
|
+
winrm set winrm/config/service/auth @{Basic="true"}
|
125
|
+
winrm set winrm/config/service @{AllowUnencrypted="true"}
|
126
|
+
```
|
127
|
+
You can read more about that on issue [#29](https://github.com/WinRb/WinRM/issues/29)
|
128
|
+
|
129
|
+
Also see [this post](http://www.hurryupandwait.io/blog/understanding-and-troubleshooting-winrm-connection-and-authentication-a-thrill-seekers-guide-to-adventure) for more general tips related to winrm connection and authentication issues.
|
130
|
+
|
131
|
+
|
132
|
+
## Current features
|
133
|
+
|
134
|
+
1. GSSAPI support: This is the default way that Windows authenticates and
|
135
|
+
secures WinRM messages. In order for this to work the computer you are
|
136
|
+
connecting to must be a part of an Active Directory domain and you must
|
137
|
+
have local credentials via kinit. GSSAPI support is dependent on the
|
138
|
+
gssapi gem which only supports the MIT Kerberos libraries at this time.
|
139
|
+
|
140
|
+
If you are using this method there is no longer a need to change the
|
141
|
+
WinRM service authentication settings. You can simply do a
|
142
|
+
'winrm quickconfig' on your server or enable WinRM via group policy and
|
143
|
+
everything should be working.
|
144
|
+
|
145
|
+
2. Multi-Instance support: Moving away from Handsoap allows multiple
|
146
|
+
instances to be created because the SOAP backend is no longer a Singleton
|
147
|
+
type class.
|
148
|
+
|
149
|
+
3. 100% Ruby: Nokogiri while faster can present additional frustration for
|
150
|
+
users above and beyond what is already required to get WinRM working.
|
151
|
+
The goal of this gem is make using WinRM easy. In V2 we plan on making
|
152
|
+
the parser swappable in case you really do need the performance.
|
153
|
+
|
154
|
+
## Contributing
|
155
|
+
|
156
|
+
1. Fork it.
|
157
|
+
2. Create a branch (git checkout -b my_feature_branch)
|
158
|
+
3. Run the unit and integration tests (bundle exec rake integration)
|
159
|
+
4. Commit your changes (git commit -am "Added a sweet feature")
|
160
|
+
5. Push to the branch (git push origin my_feature_branch)
|
161
|
+
6. Create a pull requst from your branch into master (Please be sure to provide enough detail for us to cipher what this change is doing)
|
162
|
+
|
163
|
+
### Running the tests
|
164
|
+
|
165
|
+
We use Bundler to manage dependencies during development.
|
166
|
+
|
167
|
+
```
|
168
|
+
$ bundle install
|
169
|
+
```
|
170
|
+
|
171
|
+
Once you have the dependencies, you can run the unit tests with `rake`:
|
172
|
+
|
173
|
+
```
|
174
|
+
$ bundle exec rake spec
|
175
|
+
```
|
176
|
+
|
177
|
+
To run the integration tests you will need a Windows box with the WinRM service properly configured. Its easiest to use a Vagrant Windows box (mwrock/Windows2012R2 is public on [atlas](https://atlas.hashicorp.com/mwrock/boxes/Windows2012R2) with an evaluation version of Windows 2012 R2).
|
178
|
+
|
179
|
+
1. Create a Windows VM with WinRM configured (see above).
|
180
|
+
2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
|
181
|
+
3. Ensure that the box you are running the test against has a default shell profile (check ~\Documents\WindowsPowerShell). If any of your shell profiles generate stdout or stderr output, the test validators may get thrown off.
|
182
|
+
4. Run `bundle exec rake integration`
|
183
|
+
|
184
|
+
## WinRM Author
|
185
|
+
* Twitter: [@zentourist](https://twitter.com/zentourist)
|
186
|
+
* BLOG: [http://distributed-frostbite.blogspot.com/](http://distributed-frostbite.blogspot.com/)
|
187
|
+
* Add me in LinkedIn: [http://www.linkedin.com/in/danwanek](http://www.linkedin.com/in/danwanek)
|
188
|
+
* Find me on irc.freenode.net in #ruby-lang (zenChild)
|
189
|
+
|
190
|
+
## Maintainers
|
191
|
+
* Paul Morton (https://github.com/pmorton)
|
192
|
+
* Shawn Neal (https://github.com/sneal)
|
193
|
+
|
194
|
+
[Contributors](https://github.com/WinRb/WinRM/graphs/contributors)
|
data/Rakefile
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
require 'rubocop/rake_task'
|
6
|
-
require 'bundler/gem_tasks'
|
7
|
-
|
8
|
-
# Change to the directory of this file.
|
9
|
-
Dir.chdir(File.expand_path('../', __FILE__))
|
10
|
-
|
11
|
-
desc 'Open a Pry console for this library'
|
12
|
-
task :console do
|
13
|
-
require 'pry'
|
14
|
-
require 'winrm'
|
15
|
-
ARGV.clear
|
16
|
-
Pry.start
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
20
|
-
task.pattern = 'spec/*_spec.rb'
|
21
|
-
task.rspec_opts = ['--color', '-f documentation']
|
22
|
-
task.rspec_opts << '-tunit'
|
23
|
-
end
|
24
|
-
|
25
|
-
# Run the integration test suite
|
26
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
27
|
-
task.pattern = 'spec/*_spec.rb'
|
28
|
-
task.rspec_opts = ['--color', '-f documentation']
|
29
|
-
task.rspec_opts << '-tintegration'
|
30
|
-
end
|
31
|
-
|
32
|
-
RuboCop::RakeTask.new
|
33
|
-
|
34
|
-
task default: [:spec, :rubocop]
|
35
|
-
|
36
|
-
task all: [:default, :integration]
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'bundler/gem_tasks'
|
7
|
+
|
8
|
+
# Change to the directory of this file.
|
9
|
+
Dir.chdir(File.expand_path('../', __FILE__))
|
10
|
+
|
11
|
+
desc 'Open a Pry console for this library'
|
12
|
+
task :console do
|
13
|
+
require 'pry'
|
14
|
+
require 'winrm'
|
15
|
+
ARGV.clear
|
16
|
+
Pry.start
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
20
|
+
task.pattern = 'spec/*_spec.rb'
|
21
|
+
task.rspec_opts = ['--color', '-f documentation']
|
22
|
+
task.rspec_opts << '-tunit'
|
23
|
+
end
|
24
|
+
|
25
|
+
# Run the integration test suite
|
26
|
+
RSpec::Core::RakeTask.new(:integration) do |task|
|
27
|
+
task.pattern = 'spec/*_spec.rb'
|
28
|
+
task.rspec_opts = ['--color', '-f documentation']
|
29
|
+
task.rspec_opts << '-tintegration'
|
30
|
+
end
|
31
|
+
|
32
|
+
RuboCop::RakeTask.new
|
33
|
+
|
34
|
+
task default: [:spec, :rubocop]
|
35
|
+
|
36
|
+
task all: [:default, :integration]
|