본문 바로가기

Programming/Python

[Python] Jupyter Notebook Remote Configuration

반응형
# jupyter notebook --generate-config
Writing default config to: /home/userid/.jupyter/jupyter_notebook_config.py

# jupyter notebook password
Enter password: 
Verify password: 
[NotebookPasswordApp] Wrote hashed password to /home/userid/.jupyter/jupyter_notebook_config.json

# cd /home/userid/.jupyter/

# cat jupyter_notebook_config.json
{
  "NotebookApp": {
    "password": "~~~~~~~~~~"	// 아래 c.NotebookApp.password 에 대입할 값
  }
}


# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem
Generating a RSA private key
...........................................................................+++++
...........................................................+++++
writing new private key to 'mykey.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:Seoul
Locality Name (eg, city) []:Jongno-gu
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MYCOMPANY
Organizational Unit Name (eg, section) []:Study
Common Name (e.g. server FQDN or YOUR name) []:MYCOM
Email Address []:mymail@myaddress.com


# vi jupyter_notebook_config.py
...
c.NotebookApp.allow_origin = '*'
...
c.NotebookApp.certfile = u'/home/userid/.jupyter/mycert.pem'
...
c.NotebookApp.ip = '*'
...
c.NotebookApp.keyfile = u'/home/userid/.jupyter/mykey.key'
...
c.NotebookApp.notebook_dir = u'/data001/userid/Study/Python/Jupyter_Notebook'
...
c.NotebookApp.open_browser = False
...
c.NotebookApp.password = u'~~~~~~~~~~'
...
c.NotebookApp.password_required = True
...
c.NotebookApp.port = 8888
...
c.FileContentsManager.delete_to_trash = False
...
저장 및 종료

# jupyter notebook
[I 14:42:02.136 NotebookApp] Loading IPython parallel extension
[I 14:42:02.137 NotebookApp] Serving notebooks from local directory: /data001/userid/Study/Python/Jupyter_Notebook
[I 14:42:02.137 NotebookApp] Jupyter Notebook 6.5.2 is running at:
[I 14:42:02.138 NotebookApp] https://MYCOM:8888/
[I 14:42:02.138 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

 

openssl Encrypt certificate 설정(비공인)으로 접속시 브라우저 주소창에 https:// 명시적으로 사용해야함..

 

참고: https://jupyter-notebook.readthedocs.io/en/stable/public_server.html

 

Running a notebook server — Jupyter Notebook 6.5.2 documentation

Content-Security-Policy (CSP) Certain security guidelines recommend that servers use a Content-Security-Policy (CSP) header to prevent cross-site scripting vulnerabilities, specifically limiting to default-src: https: when possible. This directive causes t

jupyter-notebook.readthedocs.io

 

반응형