Ask permission for starting vagrant SSH tunnels

This commit is contained in:
Kris Lamoureux 2023-09-16 00:04:58 -04:00
parent 2c4fcbacc3
commit 8fed63792b
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925

View File

@ -17,16 +17,26 @@ unset PKILL_ANSWER
# Function to create the SSH tunnel # Function to create the SSH tunnel
function ssh_connect { function ssh_connect {
printf "[INFO]: Starting new vagrant SSH tunnel on PID " read -rp "Start a new vagrant SSH tunnel? [y/N]"
sudo -u "$USER" ssh -fNT -i "$PRIVATE_KEY" \ echo
-L 8443:localhost:8443 \ case "$PSTART_ANSWER" in
-L 80:localhost:80 \ [yY])
-L 443:localhost:443 \ printf "[INFO]: Starting new vagrant SSH tunnel on PID "
-o UserKnownHostsFile=/dev/null \ sudo -u "$USER" ssh -fNT -i "$PRIVATE_KEY" \
-o StrictHostKeyChecking=no \ -L 8443:localhost:8443 \
vagrant@"$HOST_IP" 2>/dev/null -L 80:localhost:80 \
sleep 2 -L 443:localhost:443 \
pgrep -f "$MATCH_PATTERN" -o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
vagrant@"$HOST_IP" 2>/dev/null
sleep 2
pgrep -f "$MATCH_PATTERN"
;;
*)
echo "[INFO]: Delined to start a new vagrant SSH tunnel"
exit 0
;;
esac
} }
# Check for valid PRIVATE_KEY location # Check for valid PRIVATE_KEY location