最近工作站的驅(qū)動(dòng)崩了硅确,無(wú)法顯示圖形界面,也沒辦法teamviewer了近迁,這時(shí)候又需要運(yùn)行ipython notebook艺普,咋辦呢,幸好搜羅到兩種方法遠(yuǎn)程訪問(wèn)jupyter notebook的方法:
方法1. ssh遠(yuǎn)程使用jupyter notebook
- 在遠(yuǎn)程服務(wù)器上鉴竭,啟動(dòng)jupyter notebooks服務(wù):
jupyter notebook --no-browser --port=8889
- 在本地終端中啟動(dòng)SSH:
ssh -N -f -L localhost:8888:localhost:8889 username@serverIP
其中: -N 告訴SSH沒有命令要被遠(yuǎn)程執(zhí)行歧譬; -f 告訴SSH在后臺(tái)執(zhí)行; -L 是指定port forwarding的配置搏存,遠(yuǎn)端端口是8889瑰步,本地的端口號(hào)的8888。
注意:username@serverIP替換成服務(wù)器的對(duì)應(yīng)賬號(hào)祭埂。
- 最后打開瀏覽器面氓,訪問(wèn):http://localhost:8888/
方法2. 利用jupyter notebook自帶的遠(yuǎn)程訪問(wèn)功能
官方指南在此:官方指南
- 生成默認(rèn)配置文件
jupyter notebook --generate-config
- 生成訪問(wèn)密碼(token)
終端輸入ipython
兵钮,設(shè)置你自己的jupyter訪問(wèn)密碼蛆橡,注意復(fù)制輸出的sha1:xxxxxxxx
密碼串
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:xxxxxxxxxxxxxxxxx'
- 修改
./jupyter/jupyter_notebook_config.py
中對(duì)應(yīng)行如下
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha:ce...剛才復(fù)制的那個(gè)密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #可自行指定一個(gè)端口, 訪問(wèn)時(shí)使用該端口
- 在服務(wù)器上啟動(dòng)
jupyter notebook
jupyter notebook
- 最后打開瀏覽器,訪問(wèn):http://ip:8888/
方法3:
配置自己的config文件掘譬,如./jupyter/jupyter_notebook_config_backup.py
jupyter notebook --config ./jupyter/jupyter_notebook_config_backup.py