您好,登录后才能下订单哦!
这个问题搞了我2天时间,所以要好好记录一下。对于Windows Server 2012之前和Server 2016之后的处理方式是不一样的,我在误打误撞中,用了2012的方法解决了2016的问题, 因为我不知道忘记密码的EC2是2016版本。
而且Windows的这类问题(忘记key pair和密码)的处理方式比Linux的要复杂。
创建一个新的EC2 Instance,tag标记为new-instance
以下这步很关键,之前的尝试我都弄错了
另外我之前看文档说可以通过修改Ec2Config service来实现密码修改,后来摸索后才发现这在2012及之前的版本才可以,而我的忘记密码的服务器是2016版本,这也是我奇怪之前没有在路径下看到C:\Program Files\Amazon\Ec2ConfigService这个文件夹了,所以我从2012上copy了一个到这个路径,同时修改了config.xml文件,把EC2Password改为Enabled,不知道跟这个有没关系,权且记录在案。
参考文档
适用于server 2012及其前版本:https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Config.html
适用于server 2016及其后版本:https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ResettingAdminPassword_EC2Launch.html
这个提到要完全按照步骤来,我也是受这个启发,重新看文档才发现我没有launch image,而是搞了launch new instance,这点很关键。https://stackoverflow.com/questions/50686939/resetting-administrator-password-for-aws-ec2-windows-server-2012-instance
后来收到AWS Support发来的邮件支持信息,不过我的问题已经自己解决,所以没有使用他们的方法,记录如下:
对于server 2016
In the Amazon IAM Console (https://console.aws.amazon.com/iam/), in the navigation pane, choose Roles, Create new role.
Choose Amazon EC2 Role for Simple Systems Manager, and then choose Select.
Under Policy Name, check AmazonEC2RoleforSSM, Next Step, enter a Role name that is meaningful to you and choose Create Role.
Open the Amazon EC2 console, https://console.aws.amazon.com/ec2/ and choose the appropriate region.
Select the affected instance, choose Actions, Instance Settings, Attach/Replace IAM role. This would attach the IAM role you just created to your instance.
From EC2 console select, "Run Command" and "Run a command" option.
Select "AWS-RunPowershellScript" from Command document
In Select Targets, Select the instance you want to reset password for. Should the instance not be populated in the list, please wait for some time so that the changes can be propagated.
Under Commands, run the following command while replacing "new_password" with your password.
net user Administrator new_password
Following the successful completion of the run command, you should now be able to log in with that local administrator password you just keyed in under step 9. Once you've regained access to the instance, change the password to a more permanent value by running the command from step 9 again in command prompt of the instance.
Another procedure you can follow to reset the password on the instance is to use the AWSSupport-ResetAccess Automation document from the Systems Manager console. This document is useful if you have lost your EC2 key pair and want to create a password-enabled AMI from your EC2 instance, so you can launch a new instance with an existing key pair. To perform this, you can follow the steps given on the link under the section headed "Systems Manager Automation AWSSupport-ResetAccess (Offline Method)":
[+] https://aws.amazon.com/premiumsupport/knowledge-center/reset-admin-password/
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。