Skip to content

Instantly share code, notes, and snippets.

@mijdavis2
Created May 22, 2021 14:35
Show Gist options
  • Save mijdavis2/2dc848d9da4cb9f637c146de9ae84c9a to your computer and use it in GitHub Desktop.
Save mijdavis2/2dc848d9da4cb9f637c146de9ae84c9a to your computer and use it in GitHub Desktop.
Get an AWS Windows EC2 password from a private IP
#!/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