本地使用远程Linux服务器运行的jupyter notebook
准备工作使用终端软件登录服务器下载jupyter notebook pip install jupyter notebook生成配置文件 jupyter notebook --generate-config 或者该文件已生成在/.jupyter/生成密钥输入 ipython打开ipythonIn[1]:from notebook.auth import passwdIn[2]:passwd()En
·
准备工作
- 使用终端软件登录服务器
- 下载jupyter notebook
pip install jupyter notebook
- 生成配置文件
jupyter notebook --generate-config
或者该文件已生成在/.jupyter/
生成密钥
输入 ipython
打开ipython
In[1]:from notebook.auth import passwd
In[2]:passwd()
Enter password: # 输入密码
Verify password: # 确认密码
Out[2]:'sha1:xxxxx' # 这是一段密钥 复制下来备用
修改配置文件
在服务器用户目录下打开配置文件
vim .jupyter/jupyter_notebook_config.py
按i键进入insert模式 输入以下内容
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:xxx' # 刚刚复制的密钥
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888 #随便指定一个端口,但是要记住
c.NotebookApp.allow_remote_access = True
启动jupyter notebook
jupyter notebook
本地连接
下面进行端口映射
先在本地终端输入
ssh -N -f -L localhost:xxxx:localhost:8888 -p 端口号 username@远程服务器IP
其中xxxx自定义为稍后本地要输入的port
8888要和配置文件中的port一致
端口号为远程服务器的端口号
username为远程服务器的用户名
最后 在浏览器地址栏输入 localhost:xxxx
即可打开jupyter notebook
输入在生成密钥步骤中的password即可登录
更多推荐
已为社区贡献1条内容
所有评论(0)