Skip to content

Instantly share code, notes, and snippets.

@mijdavis2
Created May 4, 2021 20:59
Show Gist options
  • Save mijdavis2/b77e0280571f6f286d2340d67aad463c to your computer and use it in GitHub Desktop.
Save mijdavis2/b77e0280571f6f286d2340d67aad463c to your computer and use it in GitHub Desktop.
Get an AWS Windows EC2 password from a private IP
#!/bin/bash
# inputs: AWS_PROFILE, IP, PATH_TO_PRIV_KEY
instance_id="$(aws --profile $1 ec2 describe-instances --filter Name=private-ip-address,Values=$2 --query 'Reservations[].Instances[].InstanceId' --output text)"
echo "Instance ID: $instance_id"
passwd="$(aws --profile $1 ec2 get-password-data --instance-id ${instance_id} --priv-launch-key $3 --query 'PasswordData' --output text)"
echo "Password: $passwd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment