-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathngrokWizard.sh
48 lines (32 loc) · 1.38 KB
/
ngrokWizard.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env sh
# Original Code by https://github.com/stringmanolo
# Dependencies:
# openssh
# tmux
if [ ! -d ~/.ssh ]; then
mkdir ~/.ssh
fi
# Check if fingerprint exists, if not add it (used to avoid manual fp confirmation)
HOSTNAME="tunnel.us.ngrok.com"
FINGERPRINT=$(ssh-keygen -F $HOSTNAME)
if [ -z "$FINGERPRINT" ]; then
ssh-keyscan -H $HOSTNAME >> ~/.ssh/known_hosts
fi
if [ -f /root/.ssh/id_ecdsa ]; then
rm /root/.ssh/id_ecdsa;
fi
if [ -f /root/.ssh/id_ecdsa.pub ]; then
rm /root/.ssh/id_ecdsa.pub;
fi
ssh-keygen -t ecdsa -b 256 -f /root/.ssh/id_ecdsa -q -P '' -N ''
echo 'Your public ECDSA key is:';
cat /root/.ssh/id_ecdsa.pub;
echo -e "\n\nOpen in your Browser https://dashboard.ngrok.com/auth/ssh-keys/new and paste the key. \nCreate an account if you need to\n\n* If you create a new account make sure to confirm email before proced futher"
read -p 'Press enter when you done with email confirmation and pasting the public ssh key in ngrok panel...'
read -p 'Write the port of your server: -> ' PORT;
echo 'Performing reverse ssh connection...'
tmux new-session -d -s "ngrok" ssh -R 0:localhost:${PORT} tunnel.us.ngrok.com tcp ${PORT};
sleep 9s
tmux capture-pane -pt ngrok | head -n 8
echo "Everything Done. You can bind your server to 127.0.0.1:$PORT now.";
echo -e "\nExamples:\npython -m http.server $PORT\nncat -lvk localhost $PORT\nnc -s localhost -p $PORT";