【发布时间】:2021-02-18 12:46:52
【问题描述】:
找到微软document。但它要求用户提示。
那么有什么方法可以在没有用户凭据(没有用户提示)的情况下进行 Rdp 吗?
【问题讨论】:
标签: virtual-machine rdp azure-vm
找到微软document。但它要求用户提示。
那么有什么方法可以在没有用户凭据(没有用户提示)的情况下进行 Rdp 吗?
【问题讨论】:
标签: virtual-machine rdp azure-vm
如果你有IP,你可以在Powershell中做:
$rdpIp = "dottedIP.or.DNSName.of.VM"
cmdkey /generic:TERMSRV/$rdpIp /user:username /pass:"password"
mstsc /v:$rdpIp
cmdkey /delete:TERMSRV/$rdpIp
更进一步,如果您安装Powershell Secrets Management(并按照文档配置秘密存储),您可以按如下方式设置凭据:
#isolate your username and password from the connection script itself
Set-Secret -Name MyRDPUserName -Secret "MyUserNameValue"
Set-Secret -Name MyRDPPassword -Secret "MyPasswordValue"
然后连接的脚本如下所示:
$rdpIp = "dottedIP.or.DNSName.of.VM"
#get the secrets from the store
$user = Get-Secret -Name MyRDPUserName -AsPlainText
$pass = Get-Secret -Name MyRDPPassword -AsPlainText
cmdkey /generic:TERMSRV/$rdpIp /user:"$user" /pass:"$pass"
#erase the values from your Powershell session
$user = $null
$pass = $null
mstsc /v:$rdpIp
#remove the stored credential
cmdkey /delete:TERMSRV/$rdpIp
【讨论】: