Connect to Jupyter Notebook on a Remote Server

The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Jupyter notebook is the most popular tool among data scientists. It provides the ease and interactive way of analyzing data and model prototyping.

If you are running a Jupyter notebook from laptop and handling small dataset, it is easy to use Jupyter notebook. But if you are handling large dataset and data computation will be expensive and you need more powerful system or remote servers. If remote server has GUI, you can connect to remote server through some remote access software and use Jupyter notebook normally. But if remote server doesn’t have GUI. In this situation, you have to run Jupyter notebook and open it in desktop browser. There are two ways to access Jupyter notebook running on remote servers:

If you are running a Jupyter notebook from laptop and handling small dataset, it is easy to use Jupyter notebook. But if you are handling large dataset and data computation will be expensive and you need more powerful system or remote servers. If remote server has GUI, you can connect to remote server through some remote access software and use Jupyter notebook normally. But if remote server doesn’t have GUI. In this situation, you have to run Jupyter notebook and open it in desktop browser. There are two ways to access Jupyter notebook running on remote servers:

1) Reverse Proxy

2) SSH Tunneling

This post will explain how to access the remote server using SSH tunneling.

SSH Tunneling: Also known as port forwarding. It will setup connection from local point to remote server. Suppose IP address of remote machine is xx.xx.xx.xx. These are the steps to follow:

1) Connect to remote machine: ssh user@xx.xx.xx.xx

2) Access Jupyter notebook: Start Jupyter notebook on port 1234 (default is 8888).

jupyter notebook — no-browser — port 1234

This command will give URL with token

http://localhost:8888/?token=Jupyter_token_1234567890

Till now, you have just open Jupyter notebook on remote server. To open application, you need to connect application using SSH tunneling.

3) Connect to Jupyter notebook using SSH tunneling: SSH is command to open SSH connection. Port forwarding or SSH tunneling can be done using -L flag option. So run following command where 1234 is server port where Jupyter notebook is running.

ssh -L 8000:localhost:1234 user@xx.xx.xx.xx

Now, you can open this http://localhost:8000 in local web browser. It will prompt following window.

Enter the token, you got in step 2 (Token=Jupyter_token_1234567890). Now, you can start working on Jupyter notebook.

Thank you for Reading!

Leave a Reply

Your email address will not be published. Required fields are marked *