如何通过CloudFormation设置AWS上Windows Server计算机的管理员密码? [英] How to set the administrator password for a Windows Server machine on AWS from CloudFormation?

查看:132
本文介绍了如何通过CloudFormation设置AWS上Windows Server计算机的管理员密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在部署CloudFormation模板,该模板将从 Windows_Server-2019-English-Full-Base-2020.05.13 AMI启动EC2实例.

I am deploying a CloudFormation template which launches an EC2 instance from the Windows_Server-2019-English-Full-Base-2020.05.13 AMI.

默认情况下,Windows Server映像具有Administrator用户.要通过RDP连接到实例,我必须导航到控制台,单击 Connect ,然后从控制台获取生成的随机密码.

By default, the Windows Server image has an Administrator user. To connect to the instance via RDP, I have to navigate to the console, click on Connect and then get the generated random password from the console.

是否可以将RDP密码设置为自定义值?我想从CloudFormation模板的UserData部分中做到这一点.

Is there a way I can set the RDP password to a custom value? I would like to do this from the CloudFormation template, in the UserData section.

推荐答案

基于评论.

解决方案是在UserData 中使用以下命令:

The solution was to use the following command in UserData:

net user Administrator "new_password"

该命令,如 docs <中所述/a>,可用于更改管理员密码.

The command, as explained in the docs, can be used to change admin password.

之所以可行,是因为UserData是在管理员帐户(

This works because UserData executes under administrator account (ref):

在生成随机密码时,会从本地管理员帐户执行用户数据脚本.

User data scripts are executed from the local administrator account when a random password is generated.

这篇关于如何通过CloudFormation设置AWS上Windows Server计算机的管理员密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆