远程服务器端
1. 生成jupyter notebook配置文件(终端输入命令)
jupyter notebook --generate-config
2. 打开配置文件
vi ~/.jupyter/jupyter_notebook_config.py
3. 编辑配置文件
c.ServerApp.ip = '0.0.0.0'
c.ServerApp.port = 8888
c.ServerApp.allow_remote_access = True
c.ServerApp.password = 'your_password_here' #生成的哈希密码
c.ServerApp.notebook_dir = '/path/to/your/notebook/directory' # jupyter 实际安装位置
在终端输入
jupyter notebook password
输入您想要的密码,然后系统将生成哈希值。将生成的哈希值复制并粘贴到配置文件中。
4. 重启jupyter notebook
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser
或者,这一步还可以在服务器上用 nohup 后台挂起运行jupyter:
nohup jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser > jupyter.out 2>&1 &
本地
5.使用ssh将jupyter notebook 映射到本地
ssh -L8888:localhost:8888 your_username@remote_server_ip #服务器的8888端口隐射到本地的8888端口