Skip to content

Instantly share code, notes, and snippets.

@retyui
Created June 5, 2020 19:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save retyui/7115bb6acf151351a143ec8f96a7c561 to your computer and use it in GitHub Desktop.
Save retyui/7115bb6acf151351a143ec8f96a7c561 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -z "$NGROK_TOKEN" ]]; then
echo "Please set 'NGROK_TOKEN'"
exit 2
fi
if [[ -z "$USER_PASS" ]]; then
echo "Please set 'USER_PASS' for user: $USER"
exit 3
fi
echo "### Install ngrok ###"
wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip
unzip ngrok-stable-linux-386.zip
chmod +x ./ngrok
echo "### Update user: $USER password ###"
echo -e "$USER_PASS\n$USER_PASS" | sudo passwd "$USER"
echo "### Start ngrok proxy for 22 port ###"
rm -f .ngrok.log
./ngrok authtoken "$NGROK_TOKEN"
./ngrok tcp 22 --log ".ngrok.log" &
sleep 10
HAS_ERRORS=$(grep "command failed" < .ngrok.log)
if [[ -z "$HAS_ERRORS" ]]; then
echo ""
echo "=========================================="
echo "To connect: $(grep -o -E "tcp://(.+)" < .ngrok.log | sed "s/tcp:\/\//ssh $USER@/" | sed "s/:/ -p /")"
echo "=========================================="
else
echo "$HAS_ERRORS"
exit 4
fi
@qwqlemon2333
Copy link

Your ngrok-agent version "2.3.41" is too old. The minimum supported agent version for your account is "3.2.0". Please update to a newer version with ngrok update, by downloading from https://ngrok.com/download, or by updating your SDK version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment