0

I have created a Windows Instance on AWS through FOG gem, I get the password through:

connection.get_password_data(instance_id).body['passwordData']

This password is encrypted, base64-encoded password of the instance.

How to decode and decrypt this password.

As specified in AWS documentation that, the password is encrypted using the key pair that you specified when you launched the instance.

kenorb
  • 155,785
  • 88
  • 678
  • 743
Kalyani
  • 21
  • 5

2 Answers2

0

I usually do it directly from the http://aws.amazon.com console, which will look like this: enter image description here but you can also do it thru the CLI if you have it installed:

http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-GetPassword.html

Edit: If you want to programatically decrypt a password, this may help: http://www.frontiertown.co.uk/2012/03/java-administrator-password-windows-ec2-instance/

E.J. Brennan
  • 45,870
  • 7
  • 88
  • 116
  • Thanks for replying, but I want to fetch the decrypted password through FOG gem. I am not getting any way to fetch decrypted password through FOG gem. – Kalyani Feb 09 '15 at 06:33
  • Is there any way to decrypt the password programmatically? – Kalyani Feb 09 '15 at 10:38
  • See my edit, added link to article that shows you how to decrypt a password which may help. – E.J. Brennan Feb 09 '15 at 11:29
  • Hey Brennan, Thanks for the answer. Finally Got the solution: https://github.com/tomrittervg/decrypt-windows-ec2-passwd This helped me to decrypt the password. – Kalyani Feb 09 '15 at 15:03
0

You can decrypt the password using:

  • AWS SDK
  • AWS CLI command-line tool, e.g.

    aws ec2 get-password-data --instance-id i-instanceid --priv-launch-key mykey.pem
    
  • OpenSSL command-line utility, e.g.

    printf 'BASE64ENCODEDSTRING==' | openssl rsautl -decrypt -inkey mykey.pem
    

In Ruby, you can use system() to invoke above commands. See: Calling shell commands from Ruby

kenorb
  • 155,785
  • 88
  • 678
  • 743