I’ve just found another method without using ssh.
# Install jupyterlab and ngrok
!pip install jupyterlab==2.2.9 pyngrok -q
# Run jupyterlab in background
!nohup jupyter lab --ip=0.0.0.0 &
# Make jupyterlab accessible via ngrok
from pyngrok import ngrok
print(ngrok.connect(8888))
It will then show a JupyterLab URL
http://f1fe6fb39df6.ngrok.io # for example
You can click it to run JupyterLab now. Or use the URL with VSCode for remote Jupyter kernel.
You can also use my library to make it short.
!pip install kora -q
from kora import jupyter
jupyter.start(lab=True)