Windows Password won't decrypt on AWS EC2 even with the correct private key
AWS EC2's key management does not cope with SSH private keys that have passwords set (are encrypted). It doesn't detect this, and simply fails with an uninformative error.
If your private key is stored encrypted on disk (like it should be, IMO) you must decrypt it to paste it into AWS's console.
Rather than doing that, consider decrypting the password locally, so you don't have to send your private key to AWS. Get the encrypted password data (base64 encoded) from the server log after startup, or using get-password-data or the corresponding API requests.
You can then base64 decode and decrypt the result:
base64 -d /tmp/file | openssl rsautl -decrypt -inkey /path/to/aws/private/key.pem
(OpenSSH private keys are accepted by openssl rsautl
).
The issue with failing to handle password protected keys with a useful error also affects the ec2-get-password
command.
See also:
- EC2 Windows - Get Administrator Password
- decrypt password with OpenSSL
- bug report on AWS forums - please chime in.
This is what worked for me in macOS:
openssl rsa -in $HOME/.ssh/aws-remote -out /Users/home/desktop/unencrypted-rsa.txt
It's noting that you can tell if your .pem file is encrypted with a password by looking for the following line. If it's present, you need to decrypt it before using it with Amazon:
Proc-Type: 4,ENCRYPTED