Skip to content

Instantly share code, notes, and snippets.

@lelandbatey
Created September 15, 2020 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lelandbatey/46f4f292d23fefc872321931c03bd6bf to your computer and use it in GitHub Desktop.
Save lelandbatey/46f4f292d23fefc872321931c03bd6bf to your computer and use it in GitHub Desktop.
Refresh local AWS creds via Jumpcloud OTP
#!/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