Skip to content

Instantly share code, notes, and snippets.

@sandromello
Created September 22, 2025 21:36
Show Gist options
  • Select an option

  • Save sandromello/4678dd2fbbb8f97adab80d15013cba1a to your computer and use it in GitHub Desktop.

Select an option

Save sandromello/4678dd2fbbb8f97adab80d15013cba1a to your computer and use it in GitHub Desktop.

Revisions

  1. sandromello created this gist Sep 22, 2025.
    26 changes: 26 additions & 0 deletions jump-host-script.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/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