본문 바로가기

공부기록/Linux

[configuration] Jupyter Notebook 터널링

Config 생성 및 수정

 

Config 파일 생성 + password 해시값 얻기

(base) $ jupyter notebook --generate-config
Writing default config to: /home/user/.jupyter/jupyter_notebook_config.py

(base) $ python
Python 3.9.12 (main, Apr  5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd
>>> passwd()
Enter password:			# 원하는 password 입력 및 엔터
Verify password:		# verify(동일 password 입력 및 엔터)
'{$HashedValue}'    		# config에 채워넣을 값
>>> exit()

 

Config 수정: vim같은 에디터 사용해서 다음값 변경(주석처리 되어있을 경우 활성화 시키고 변경)

  • c.NotebookApp.ip = 'localhost' > ipv4로 변경 (ex) 192.168.0.222..) * 포트포워딩 되어있어서 변경함
  • c.NotebookApp.password = '' > 위의 커맨드에서 출력된 {$HashedValue} 붙여넣기
  • c.NotebookApp.port = 8888 > 원하는 포트 있으면 변경 (따로 포트점유하는거 없어서 디폴트 값인 8888 그대로 씀)

저장 후 jupyter notebook 실행: session 살아있어야 하므로 tmux 활용해서 켜두고 원격으로 접속

(아직 다른 네트워크에서는 접속 안됨)

(base) $ jupyter notebook
[W 2023-04-17 14:22:56.586 LabApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2023-04-17 14:22:56.586 LabApp] 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2023-04-17 14:22:56.586 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2023-04-17 14:22:56.586 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2023-04-17 14:22:56.592 LabApp] JupyterLab extension loaded from /home/user/anaconda3/lib/python3.9/site-packages/jupyterlab
[I 2023-04-17 14:22:56.592 LabApp] JupyterLab application directory is /home/user/anaconda3/share/jupyter/lab
[I 14:22:56.595 NotebookApp] Serving notebooks from local directory: /home/user
[I 14:22:56.595 NotebookApp] Jupyter Notebook 6.4.8 is running at:
[I 14:22:56.595 NotebookApp] http://192.168.0.222:8888/
[I 14:22:56.595 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 14:22:56.597 NotebookApp] No web browser found: could not locate runnable browser.

 


다른 네트워크에서 접속할 경우

iptime 관리도구(보통 192.168.0.1)에서 아래 부분 설정해줘야 함

  • Port Forwarding (외부포트 > 8888로 맵핑)
  • DDNS (어쩌고저쩌고.iptime.org)

DDNS 등록 확인 (사용자 ID의 경우 id@example.com)

 

다른 네트워크에서 원격 접속

(비밀번호 입력 후 접속되는지 확인)

 

신나는 외근 가자ㅏㅏ