透過遠端主機執行jupyter-notebook === 透過建立ssh通道,port forwarding回傳畫面 Setup jupyter-notebook on remote server through ssh tunneling ## 方法1. ssh進入主機再 `jupyter-notebook --ip=192.168.60.66 --no-browser VSB_1st_place_solution.ipynb` 即開一個webserver可直接連線 --- ## 方法2. HOW: === 我們眼前的電腦: local 遠端的伺服器電腦: remote ## 遠端(remote) 不顯示瀏覽器的方式開啟 jupyter-notebook 終端機: `jupyter notebook --no-browser --port=8889 <你的>.ipynb` ![](https://i.imgur.com/EhHPo8z.png) ## 本機端(local) 開啟一個ssh通道,並把port forward給8888 `ssh -N -L localhost:8888:localhost:8889 遠端@遠端ip` 比如 `ssh -N -L localhost:8888:localhost:8889 corleone@pds` 可以把它寫進~/.bashrc變成一個方便的命令 比如 alias jpt='ssh -N -L localhost:8888:localhost:8889 corleone@pds' (ip暱稱 可以在/etc/host 設定) ![](https://i.imgur.com/D1Q1g8x.png) 啟用後 打開瀏覽器輸入 http://localhost:8888/ ![](https://i.imgur.com/vUdbqOP.png) 要輸入token 4b469edc1fc16743ee7bbd35490dd82616c949fc82b33368 或是直接點終端機網址也行 ![](https://i.imgur.com/7BOeDsN.png) ![](https://i.imgur.com/HjsdjVe.png) 愉快的使用~(◕ ‿ ◕ ) 比較結果影片(在5G wifi下測試滾動頁面) 左邊 ssh -X 右邊ssh tunneling {%youtube BUSdHcfyxRc %} ### 缺點: 網路斷線,ssh session就要重連。 ### SSH過久沒動畫面會斷線(離開位置一陣子) 可在server端 /etc/ssh/sshd_config 加入 ```txt= ClientAliveInterval 120 ClientAliveCountMax 720 ``` https://bjornjohansen.no/ssh-timeout?fbclid=IwAR3va1mCUWO_2fPIYQ4ZZjV3ymccyceDfoXm7xrEftjNmqDPiqxzmiJG_DA 參考和延伸閱讀 === xrdp protocol: https://en.wikipedia.org/wiki/Xrdp 我的同事 [遠端使用jupyter notebook](https://amber-md.github.io/pytraj/latest/tutorials/remote_jupyter_notebook?fbclid=IwAR0Kz9b__R4j-Dx2nUTiXiMfoZX9ZbuZXeooH5C4yxeUPmpJ0DFhz2hb798) screen -r 進入session ctr+ A +D 跳出 wifi斷線g netstat -tnpa | grep 'ESTABLISHED.*sshd' 清除ssh session sudo killall ssh ps aux | grep ssh ###### tags: `tutorial` `ml`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up