Created
May 4, 2021 20:59
-
-
Save mijdavis2/b77e0280571f6f286d2340d67aad463c to your computer and use it in GitHub Desktop.
Get an AWS Windows EC2 password from a private IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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