Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tutorial:adm:configuration_-_winrm [2024/01/30 06:45] erbenr |
tutorial:adm:configuration_-_winrm [2024/02/05 05:17] erbenr |
||
---|---|---|---|
Line 9: | Line 9: | ||
<code powershell> | <code powershell> | ||
Test-WSMan | Test-WSMan | ||
+ | |||
</ | </ | ||
Line 24: | Line 25: | ||
<code powershell> | <code powershell> | ||
winrm e winrm/ | winrm e winrm/ | ||
+ | |||
</ | </ | ||
Line 61: | Line 63: | ||
<code powershell> | <code powershell> | ||
winrm set winrm/ | winrm set winrm/ | ||
+ | |||
</ | </ | ||
Line 71: | Line 74: | ||
winrm set winrm/ | winrm set winrm/ | ||
winrm set winrm/ | winrm set winrm/ | ||
+ | |||
</ | </ | ||
Line 78: | Line 82: | ||
<code powershell> | <code powershell> | ||
winrm set winrm/ | winrm set winrm/ | ||
+ | |||
</ | </ | ||
Line 85: | Line 90: | ||
<code powershell> | <code powershell> | ||
winrm set winrm/ | winrm set winrm/ | ||
+ | |||
</ | </ | ||
Line 96: | Line 102: | ||
winrm set winrm/ | winrm set winrm/ | ||
Enable-WSManCredSSP -Role Server | Enable-WSManCredSSP -Role Server | ||
+ | |||
</ | </ | ||
Line 115: | Line 122: | ||
<code powershell> | <code powershell> | ||
winrm configSDDL default | winrm configSDDL default | ||
+ | |||
</ | </ | ||
Line 122: | Line 130: | ||
<code powershell> | <code powershell> | ||
Restart-Service winrm | Restart-Service winrm | ||
+ | |||
</ | </ | ||
Line 133: | Line 142: | ||
<code shell> | <code shell> | ||
nc -vz HOST PORT | nc -vz HOST PORT | ||
+ | |||
</ | </ | ||
Line 140: | Line 150: | ||
<code powershell> | <code powershell> | ||
Test-WSMan -ComputerName HOST or Test-netConnection HOST -Port PORT | Test-WSMan -ComputerName HOST or Test-netConnection HOST -Port PORT | ||
+ | |||
</ | </ | ||
Line 145: | Line 156: | ||
Now we know if we are able to connect to the WinRM port. In case the port is not accessible it can be probably blocked in firewall. Next we want to try to connect to WinRM. Install [[: | Now we know if we are able to connect to the WinRM port. In case the port is not accessible it can be probably blocked in firewall. Next we want to try to connect to WinRM. Install [[: | ||
- | < | + | python>> |
- | >>> | + | |
+ | < | ||
+ | import winrm>>> | ||
>>> | >>> | ||
>>> | >>> | ||
+ | |||
</ | </ | ||
Line 154: | Line 168: | ||
For connecting via HTTPS use this lane. The difference is in URL where we need to use https and port 5986. Then we are using one more argument where we specify path to trust store | For connecting via HTTPS use this lane. The difference is in URL where we need to use https and port 5986. Then we are using one more argument where we specify path to trust store | ||
- | <code python>>>> | + | s = winrm.Session('', |
+ | |||
+ | <code python>>>>> | ||
</ | </ | ||
Line 162: | Line 179: | ||
<code python> | <code python> | ||
r = s.run_ps(' | r = s.run_ps(' | ||
+ | |||
</ | </ | ||
Line 281: | Line 299: | ||
print " | print " | ||
print " | print " | ||
+ | |||
</ | </ | ||
Line 309: | Line 328: | ||
The tested way to generate self signed certificate on linux via tutorial which can be found [[https:// | The tested way to generate self signed certificate on linux via tutorial which can be found [[https:// | ||
- | Create and export self signed certificate with powershell: | ||
Now we have certificate which is imported in our windows server and now we can configure the HTTP listener | Now we have certificate which is imported in our windows server and now we can configure the HTTP listener | ||
+ | |||
+ | Create and export self signed certificate with powershell: | ||
+ | |||
<code powershell> | <code powershell> | ||
$pathToCertificate=" | $pathToCertificate=" | ||
Line 319: | Line 340: | ||
DnsName = ' | DnsName = ' | ||
CertStoreLocation = ' | CertStoreLocation = ' | ||
- | KeyExportPolicy =' | + | KeyExportPolicy =' |
- | KeySpec =' | + | KeySpec =' |
KeyLength =' | KeyLength =' | ||
KeyAlgorithm = ' | KeyAlgorithm = ' | ||
Line 328: | Line 349: | ||
#$cert = New-SelfSignedCertificate -Subject " | #$cert = New-SelfSignedCertificate -Subject " | ||
$cert = New-SelfSignedCertificate @params | $cert = New-SelfSignedCertificate @params | ||
- | Export-Certificate -Cert $cert -FilePath " | + | Export-Certificate -Cert $cert -FilePath " |
$mypwd = ConvertTo-SecureString -String " | $mypwd = ConvertTo-SecureString -String " | ||
Export-PfxCertificate -Cert $cert -FilePath " | Export-PfxCertificate -Cert $cert -FilePath " | ||
+ | |||
</ | </ | ||
List certificate in windows certificate storage: | List certificate in windows certificate storage: | ||
+ | |||
<code powershell> | <code powershell> | ||
Get-ChildItem -Path Cert: | Get-ChildItem -Path Cert: | ||
+ | |||
</ | </ | ||
Configure WinRM listener with HTTPS certficate: | Configure WinRM listener with HTTPS certficate: | ||
+ | |||
<code powershell> | <code powershell> | ||
winrm create winrm/ | winrm create winrm/ | ||
for deleting | for deleting | ||
winrm delete winrm/ | winrm delete winrm/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | Create firewall rule for WinRM HTTPS: | ||
+ | |||
+ | <code powershell> | ||
+ | New-NetFirewallRule -Displayname 'WinRM - Powershell remoting HTTPS-In' | ||
+ | |||
</ | </ | ||