Created
September 22, 2025 21:36
-
-
Save sandromello/4678dd2fbbb8f97adab80d15013cba1a to your computer and use it in GitHub Desktop.
jump-host-script.sh
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 | |
| set -eo pipefail | |
| LINUX_TARGET_USER= | |
| while IFS= read -r line; do | |
| [ -z "$line" ] && continue | |
| USER_EMAIL=$(echo -n $line | awk '{print $1}') | |
| if [ $USER_EMAIL == "$HOOP_USER_EMAIL" ]; then | |
| LINUX_USER=$(echo -n $line | awk '{print $2}') | |
| if [ -z ${LINUX_USER} ]; then | |
| echo "mapping not found for $USER_EMAIL!" | |
| exit 1 | |
| fi | |
| LINUX_TARGET_USER=$LINUX_USER | |
| echo "found linux user mapping for $USER_EMAIL -> $LINUX_USER!" | |
| break; | |
| fi | |
| done <<< "$USER_LIST" | |
| if [ -z "$LINUX_TARGET_USER" ]; then | |
| echo "unable to find valid mapping to login" | |
| exit 1 | |
| fi | |
| sudo su $LINUX_TARGET_USER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment