Remote login localhost jupyter notebook through AWS EC2 instance by ssh reverse tunnel
Note: This is before I know ngrok
, and It is a work note for me to remember all steps I did to make this work.
Referenc below has more detail explanation.
Why
I would like to let my colleague to test my jupyter notebook, but we are not in the same office
Setup ssh reverse tunnel
- Create a AWS EC2 instance, t2.micro should be good enough
- Open Inbound port (such as 19999) for jupyter notebook
- open ssh reverse tunnel from local (8888 for jupyter port) to ec2 (19999)
1
2# For example, in the terminal of local computer
sudo ssh -i "ebs-ttt.pem" -N -R 19999:localhost:8888 ubuntu@ec2-34-XXX-YYY-ZZZ.us-west-2.compute.amazonaws.com
Set up Jupyter notebook for remote login
1 | (base) C:\workspace\NexMotion-Python_API>jupyter notebook --generate-config |
Then, open jupyter_notebook_config.py
and uncomment following line and set to True
c.NotebookApp.allow_remote_access = True
Set up Jupyter notebook password
For now, jupyter notebook can remote login by token, but it would be better to setup password.
1 | (base) C:\workspace\NexMotion-Python_API>jupyter notebook password |
Reference
https://jupyter-notebook.readthedocs.io/en/stable/public_server.html
https://github.com/jupyterhub/jupyterhub/issues/2230
Issue
ipywidget not display correct when login from remote (** need disable cache**)
https://github.com/jupyter-widgets/ipywidgets/issues/1411
For Chrome
open chrome console (dev tool), let browser refresh (F5) get new copy from server (not use local cache)
https://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#7000899
for iOS device (mobile)
https://stackoverflow.com/questions/9218123/how-to-disable-cache-on-ios-safari
For iOS
Open Settings
Navigate to Safari
> Advanced
Enable Web Inspector
Switch back to Safari and load a web page
For Mac Desktop
Open Safari
Navigate to Safari
> Preferences
> Advanced tab
Enable the Develop menu
In the Develop
menu, select Your iOS Device Name
> The Page You Want to Debug
Press Command-Shift-R to reload while disabling cache
Bonus: This is a full Web Inspector on your computer inspecting a page on your iOS device