【问题标题】:Connect to Azure Virtual Machine with WinRM Enabled using Http使用 Http 连接到启用 WinRM 的 Azure 虚拟机
【发布时间】:2018-04-17 17:00:02
【问题描述】:

我可以使用 http://terraformrg.southeastasia.cloudapp.azure.com/ 访问我的 azure vm (windows),但无法使用 https://terraformrg.southeastasia.cloudapp.azure.com/ 访问(机器中没有 SSL)。但是我在这个虚拟机中为 https 启用了 443 端口。我看到我的虚拟机中同时运行 http 和 https WinRM 侦听器,即没有缩略图的 http 和带有缩略图的 https。

我的问题是,我可以使用连接到启用 WinRM 的 azure VM 吗? 吗?还是这里的 https 是强制性的?

【问题讨论】:

  • 您是否在防火墙中打开了端口并为所有端口添加了网络安全组规则?
  • 我只在 nsg 中为 http 和 https 添加了规则。我认为这对于 azure vm 来说已经足够了。防火墙还有什么作用?是否需要通过登录 VM 或通过 azure 门户来完成?我对网络交易不公平:)
  • 您需要 RDP 到机器并根据需要打开防火墙端口。默认打开的端口是 80 和 3389,因此您需要添加 443 才能使其工作。尝试添加它,如果有帮助,请告诉我。
  • 我将在防火墙中为 https 打开 443 并尝试。但是 443 是用于 https 的,我可以在不打开此防火墙端口的情况下使用 http 连接吗?类似于... Enter-PSSession -ConnectionUri terraformrg.southeastasia.cloudapp.azure.com:5985 -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck) -Authentication Negotiate?看,我为 http 使用了 5985 WinRM 端口。
  • 已尝试“$cred = Get-Credential Enter-PSSession -ConnectionUri terraformrg.southeastasia.cloudapp.azure.com:5986 -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck) -Authentication Negotiate”,但出现错误

标签: azure azure-virtual-machine winrm


【解决方案1】:

关于启用 Azure VM WinRM,您应该将端口 5985 添加到 Azure VM 的 NSG 入站规则,并将端口 5985 添加到 windows 防火墙入站规则

然后使用此脚本创建会话:

$username = 'user'
$pass = ConvertTo-SecureString -string 'password' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
$s = New-PSSession -ConnectionUri 'http://xx.xx.xx.xx:5985' -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)

希望这会有所帮助。

更新:

这是我的步骤:

WinRM 服务器:

PS C:\Users\jason> Enable-PSRemoting -force
PS C:\Users\jason> winrm quickconfig
WinRM service is already running on this machine.
WinRM is not set up to allow remote access to this machine for management.
The following changes must be made:

Configure LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.

Make these changes [y/n]? y

WinRM has been updated for remote management.

Configured LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.

客户:

PS C:\Users\jason> winrm set winrm/config/client '@{TrustedHosts = "13.78.103.201"}'
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 = 13.78.103.201

PS C:\Users\jason> $username = 'jason'
PS C:\Users\jason> $pass = ConvertTo-SecureString -string '122130869@qq' -AsPlainText -Force
PS C:\Users\jason> $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
PS C:\Users\jason> $s = New-PSSession -ConnectionUri 'http://13.78.103.201:5985' -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)

PS C:\Users\jason> Enter-PSSession -ConnectionUri 'http://13.78.103.201:5985' -Credential $cred
[13.78.103.201]: PS C:\Users\jason\Documents>
[13.78.103.201]: PS C:\Users\jason\Documents>
[13.78.103.201]: PS C:\Users\jason\Documents>

注意:将端口 5985 添加到 NSG 入站规则和 Windows 防火墙设置。

【讨论】:

  • 谢谢。刚刚在 NSG 和防火墙验证 5985 后尝试了以上 https 方式。我收到错误,因为“terraformrg.southeastasia.cloudapp.azure.com 失败并显示以下错误消息:WinRM 无法处理请求。使用 Kerberos 时发生错误代码为 0x80090311 的以下错误身份验证:当前没有可用于服务登录请求的登录服务器。”。还提到了一些可能的原因,但这里没有空间可以粘贴这些文本...
  • @JaishMathews 那只是http,而不是https,你想用https 来Winrm 吗?
  • 我正在尝试仅使用 http 并使用您放置的上述命令,即 http 本身。但是出现了我上一篇中提到的错误。评论。
  • 您使用哪种身份验证方法?您能否重新配置 WinRM(删除所有 winrm 侦听器)并尝试使用 winrm quickconfig 启用它。
  • 没有手动配置身份验证方法,但使用了 uid/pwd 文本。全部被“winrm delete winrm/config/listener?Address=*+Transport=HTTPS”&“winrm delete winrm/config/listener?Address=*+Transport=HTTP”删除运行“winrm quickconfig”。现在 winrm 有单个侦听器为“侦听器地址 = * 传输 = HTTP 端口 = 5985 启用主机名 = true URLPrefix = wsman CertificateThumbprint ListeningOn = 10.0.0.5, 127.0.0.1, ::1, 2001:0:9d38:6abd:30b2:2abd :f5ff:fffa, fe80::5efe:10.0.0.5%5, fe80::30b2:2abd:f5ff:fffa%6, fe80::bc09:a95:3b0c:8555%7" 和同样的错误
猜你喜欢
  • 2021-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-14
  • 1970-01-01
  • 2015-08-28
  • 2015-10-19
相关资源
最近更新 更多