class Aws::EC2::Instance

Public Instance Methods

decrypt_windows_password(key_pair_path) click to toggle source

@param [String, Pathname] key_pair_path @return [String]

# File lib/aws-sdk-resources/services/ec2/instance.rb, line 9
def decrypt_windows_password(key_pair_path)
  decoded = Base64.decode64(encrypted_password)
  pem_bytes = File.open(key_pair_path, 'rb') { |f| f.read }
  private_key = OpenSSL::PKey::RSA.new(pem_bytes)
  private_key.private_decrypt(decoded)
end

Private Instance Methods

encrypted_password() click to toggle source
# File lib/aws-sdk-resources/services/ec2/instance.rb, line 18
def encrypted_password
  bytes = client.get_password_data(instance_id: id).password_data
  if bytes == ''
    raise 'password not available yet'
  else
    bytes
  end
end