How To Collaborate On Your Locally Hosted Jupyter Notebook | by Kurtis Pykes | Towards Data Science

Some while back I received a call from a good friend that is learning about Data Science and wanted some help. As we are often taught about Jupyter Notebooks when learning Data Science, it was not surprise that he was using a Jupyter Notebook, but this instantly stomped me. How are we going to collaborate on a Notebook?
We ended up doing a zoom call and he gave me authorization to control his screen, but the latency was turning me crazier than the problem at hand.
Fast-forward 2 months, the tables have turned, I am now the one in need. I reached out to a Senior Data Scientist (we will call him Billy for this article) and told him of my woes:
Billy: That’s fine, Do you want to do some pair programming?
Me: Yes please that would be great. ** Sigh of relief **
Billy: Are you using Google Colabs?
Note: Turns out Colab is super easy to collaborate on.
Me: No, I am using Jupyter Notebooks locally
Billy: That’s fine. We can use Ngrok!
Me: Ah yes, Sure!
I will be totally honest... I had no clue what Ngrok was, but I had faith in my googling skills.
Ngrok exposes local servers behind NATs and firewalls to the public internet over secure tunnels. Subsequently, we are able to provide our local server to the port of a web server and this enables us to get the local address we specified — If this makes no sense to you, don’t worry about it. All I am saying is that we will obtain a public URL of our locally hosted Jupyter Notebook that we can share and use to collaborate.
Setting up Ngrok consist of 3 simple steps:
Sign Up
Sign Up
You can easily make a free account by clicking on “Sign Up”. Just fill in your credentials and you’re fired up — Link to sign up page here
2. Download
Download Ngrok that is suitable for your operating system then Unzip it once it’s downloaded.
Note: On Linux or Mac OS X you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip to extract it.
unzip /path/to/ngrok.zip
3. Connect your Account
The next step is simply authenticating your Ngrok agent, which only needs to be done once as the Authtoken is saved in the default configuration file.
Your authentication token can be accessed by going to Authentication on the side bar then Your Authtoken — See image below.
I prefer the command line set up which includes simply telling Ngrok your authentication token.
./ngrok authtoken 1g3Zd5XeTdmRTYIvOZmGVBW3hAH_2873ypJDaDf6ybyUzmSUj
Great! You are now all set up, but now you must learn to share your Jupyter Notebook.
For Jupyter Notebooks to be accessed remotely we must make some adjustments to our Jupyter Notebook configuration, and for extra security, we will add a password.
jupyter notebook --generate-config
This will return the link address to the configuration file of your Jupyter Notebook.
Writing default config to: C:\Users\Kurtis\.jupyter\jupyter_notebook_config.py
Copy the link address and run the following command
echo "NotebookApp.allow_remote_access = True" >> C:\Users\Kurtis\.jupyter\jupyter_notebook_config.py
Then we add a password...
jupyter notebook password
We now have everything required to run and connect our Jupyter Notebook so that it could be shared remotely.
Tip: In the next part we’ll need two separate terminals connected to our remote because once we run jupyter, it will occupy a window with logging. You can either open a second terminal and ssh into it again, or you can use a tool like tmux to manage them within a single terminal. (Source: ArtificialSoph Github)
Open your Jupyter Notebook by typing jupyter notebook in your terminal.
jupyter notebook
After we’ve accessed our Jupyter Notebook we tell Ngrok what port our web server is listening on.
The above image highlights the port. Thence we would tell Ngrok the port is 8888.
ngrok http [port] -host-header="localhost:[port]"
Your results should look like the one displayed below
Copy the forwarding address and share it with whoever you want to collaborate with — if you followed our steps and set up a password then you’ll have to tell them the password.
Great, now you can collaborate!
Magnificent! Now you don’t have to be stomped or put up with bad latency (because you’ve shared your screen on zoom) whenever you need to collaborate with someone on a Jupyter Notebook on their local machine (or yours for that matter) — You now know how to share your Jupyter Notebook and work on a different machine.
I enjoy connecting with people, I am most reachable on LinkedIn — Connect and stay up to date with anything new I am learning (and feel free to share what you’re learning too).