gpt4 book ai didi

azure - 使用 Http 连接到启用 WinRM 的 Azure 虚拟机

转载 作者:行者123 更新时间:2023-12-03 05:03:44 25 4
gpt4 key购买 nike

我可以使用 http://terraformrg.southeastasia.cloudapp.azure.com/ 访问我的 Azure 虚拟机(Windows)并且无法使用 https://terraformrg.southeastasia.cloudapp.azure.com/ 访问(机器中没有 SSL)。但我在此虚拟机中启用了 https 的 443 端口。我看到 http 和 https WinRM 监听器都在我的 VM 中运行,即没有缩略图的 http 和有缩略图的 https。

My question is that can I connect to my WinRM enabled azure VM using http? or is it a mandatory for https here?

最佳答案

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

然后使用此脚本创建 session :

$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 防火墙设置。

关于azure - 使用 Http 连接到启用 WinRM 的 Azure 虚拟机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49859374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com