Created
May 22, 2021 14:35
-
-
Save mijdavis2/2dc848d9da4cb9f637c146de9ae84c9a 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
#!/usr/bin/env fish | |
# inputs: AWS_PROFILE, IP, PATH_TO_PRIV_KEY | |
function get-aws-windows-password | |
set instance_id (aws --profile $argv[1] ec2 describe-instances --filter Name=private-ip-address,Values=$argv[2] --query 'Reservations[].Instances[].InstanceId' --output text) | |
echo "Instance ID: $instance_id" | |
set passwd (aws --profile $argv[1] ec2 get-password-data --instance-id $instance_id --priv-launch-key $argv[3] --query 'PasswordData' --output text) | |
echo "Password: $passwd" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment