Skip to content

Instantly share code, notes, and snippets.

@dzuluaga
Last active October 7, 2023 18:11
Show Gist options
  • Save dzuluaga/bc15dced36a2011efb523f7bb8f96bfb to your computer and use it in GitHub Desktop.
Save dzuluaga/bc15dced36a2011efb523f7bb8f96bfb to your computer and use it in GitHub Desktop.
install ngrok on Google Cloud Shell

How to install ngrok in Google Cloud Shell

These steps will surface a public endpoint through ngrok with no authentication.

1. Download ngrok

$ curl https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip -o ngrok-stable-linux-amd64.zip

2. Unzip ngrok

$ unzip ngrok-stable-linux-amd64.zip

3. Start ngrok

$ ./ngrok http 8080

Session Status                online                                                                                                                                               
Session Expires               7 hours, 58 minutes      
Version                       2.2.8      
Region                        United States (us)                   
Web Interface                 http://127.0.0.1:4040       
Forwarding                    http://42daf0b7.ngrok.io -> localhost:8080   
Forwarding                    https://42daf0b7.ngrok.io -> localhost:8080                                                                                                          
Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       1       0.00    0.00    0.00    0.00                                                                                                         

4. You're good to go

You can start making http requests to an API running in Google Cloud Shell.

$ curl https://d0045428.ngrok.io/api/events

[{"id":"AoG","title":"Actions on Google","description":null,"details":null,"date":null,"startTime":null,"endTime":null,"categories":["free","outdoor","family-friendly"],"icon":null,"image":null,"website":null,"active":true},{"id":"I9hy6idIeBr9M9ajRYrW","title":"KubeCon","description":null,"details":null,"date":null,"startTime":null,"endTime":null,"categories":["technical","external"],"icon":null,"image":null,"website":null,"active":false},{"id":"Y9FCCW4knkm93EIXqrYZ","title":"DevRel Conference","description":null,"details":null,"date":null,"startTime":null,"endTime":null,"categories":["free"],"icon":null,"image":null,"website":null,"active":false},{"id":"next2019","title":"Google Next 2019","description":"All customers, partners, and Google in a single location.","details":null,"date":null,"startTime":null,"endTime":null,"categories":null,"icon":null,"image":null,"website":null,"active":false}]%

For other versions of ngrok visit https://ngrok.com/download

Optional steps

4. Use ngrok token

As oper ngrok site. Running this command will add your account's authtoken to your ngrok.yml file. This will give you more features and all open tunnels will be listed here in the dashboard.

$ ./ngrok authtoken My_Token_from_ngrok.com

Disclaimer

My personal recommendation is to use this tool for experimental and personal projects. Therefore, I use Google Cloud Shell Project from GMail personal account that has no connectivity with any production environment, therefore it's not prone to any security issues.

@ddusi
Copy link

ddusi commented Mar 11, 2020

Hey! Can I ask you a question?
When I run ngrock, I see Permission denied errors.
I used 'chomd 777' in my home directory, but I can't.
What should I do?

@Alygnt
Copy link

Alygnt commented Apr 30, 2021

Hey! Can I ask you a question?
When I run ngrock, I see Permission denied errors.
I used 'chomd 777' in my home directory, but I can't.
What should I do?

I faced same issue

@soheilRdev
Copy link

hey ! how can i make a ssh into terminal?

@craigsims808
Copy link

You run ngrok like this

user@cloudshell:~$ ./ngrok http 8080

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