问题
I am creating the windows image with username and password using packer. It is working fine. I can able to create image.
My requirement is i need to create the windows image with key pair using packer. I have searched a lot but not found any document to create windows image with key pair.
Please let me know how to do this using packer.
回答1:
It's hard to understand your exact question but I'll make a guess.
You want to build a Windows AMI which when launched sets a random Administrator password which is encrypted with the keypair.
This is how Packer will work if don't specify any winrm_password
, and if you don't specify any ssh_keypair_name
and no ssh_private_key_file
Packer will create a temporary keypair.
If you want to use a existing keypair just define ssh_keypair_name
and ssh_private_key_file
.
The random Administrator password will be set by the instance when launching the first time and will be encrypted with the public key from the keypair. To get the password you need to decrypt it with the corresponding private ssh key. See AWS CLI - get password data and EC2 - Windows Passwords
来源:https://stackoverflow.com/questions/42138964/how-to-create-windows-image-in-packer-using-the-keypair