Created
September 15, 2020 21:54
-
-
Save lelandbatey/46f4f292d23fefc872321931c03bd6bf to your computer and use it in GitHub Desktop.
Refresh local AWS creds via Jumpcloud OTP
This file contains 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 | |
# This script runs the entire set of steps to authenticate with jumpcloud and | |
# refresh the temporarily stored AWS credentials. | |
cd "$HOME/Documents/jumpcloud_mfa/" | |
# Yes, the local OTP credentials on disk are encrypted with just the username of my user. | |
( (sleep 0.3; pkill -f "./otp.sh jumpcloud") & echo "$USER" | ./otp.sh jumpcloud-totp) | |
# otp.sh puts the current otp in my clipboard, so we get it into a variable using xclip | |
TOTP_TOKEN=$(xclip -sel clip -o -) | |
sleep 0.4 | |
saml2aws login --force --username=leland@companry.com --password="ACTUAL_JUMPCLOUD_PASSWORD_GOES HERE" --mfa-token=$TOTP_TOKEN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment