Created
January 3, 2024 13:40
-
-
Save jasalt/33e0048d0222669e866efc15f1574007 to your computer and use it in GitHub Desktop.
SSH straight to server behind dynamic NGROK address/port using new NGROK API
This file contains 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
#!/usr/bin/env bash | |
# Connect to a dynamic NGROK endpoint that changes ofter after server restart etc. | |
# Works with single active tunnel (per account) on free tier. | |
# Provides persistent or dedicated endpoint like premium experience. | |
# Requires environment variable $NGROK_APIKEY | |
NGROK_ENDPOINT=$(curl -s https://api.ngrok.com/tunnels -H "authorization: Bearer $NGROK_APIKEY" -H "ngrok-version: 2" | jq -r '.tunnels[0].public_url') | |
NGROK_HOST=$(echo "$NGROK_ENDPOINT" | cut -d':' -f2 | cut -d'/' -f3) | |
NGROK_PORT=$(echo "$NGROK_ENDPOINT" | cut -d':' -f3) | |
ssh -p $NGROK_PORT as@$NGROK_HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment