Skip to content

Commit

Permalink
Merge pull request inovex#81 from henninge/login-script
Browse files Browse the repository at this point in the history
Improve login script
  • Loading branch information
maxbischoff committed Oct 17, 2022
2 parents 00ad46b + 4a7c9eb commit 87e3fe5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/log_me_in.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ menu_from_array ()
# Check the selected menu item number
if [ 1 -le "$REPLY" ] && [ "$REPLY" -le $# ];
then
student=$item
echo -n $item
break;
else
echo "Wrong selection: Select any number from 1-$#"
echo >&2 "Wrong selection: Select any number from 1-$#"
fi
done
}
Expand All @@ -26,11 +26,12 @@ do
students+=("${student%.*}")
done

menu_from_array "${students[@]}"
student=$(menu_from_array "${students[@]}")
hosts=($(cat ips/${student}.txt | cut -d: -f1 ))
host=$(menu_from_array "${hosts[@]}" )

# Find the script location. Inspired by: https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself
scriptLocation="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# fetch first ip address
ip=$(head -n 1 "${scriptLocation}/../ips/${student}.txt" | awk -F' ' '{print $2}')
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i "keys/${student}" "student@${ip}"
fqdn="${host}.training-lf-kubernetes.fra.ics.inovex.io"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i "keys/${student}" "student@${fqdn}"

0 comments on commit 87e3fe5

Please sign in to comment.