ssh - 如何远程启动IPython笔记本?

标签 ssh ipython jupyter-notebook

按照这些说明进行操作(Running a notebook serverRemote access to IPython Notebooks )我按如下方式进行:

在远程服务器上:

1) 设置NotebookApp.password()

In [1]: from IPython.lib import passwd
In [2]: passwd()    
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

2)创建个人资料

user@remote_host$ ipython profile create 

3)编辑~/.ipython/profile_default/ipython_notebook_config.py

# Password to use for web authentication
c = get_config()
c.NotebookApp.password =
u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

4) 在端口 8889 上启动笔记本

user@remote_host$ ipython notebook --no-browser --port=8889

笔记本启动

[I 16:08:10.012 NotebookApp] Using MathJax from CDN:https://cdn.mathjax.org/mathjax/latest/MathJax.js

[W 16:08:10.131 NotebookApp] Terminals not available (error was No module named 'terminado')

[I 16:08:10.132 NotebookApp] Serving notebooks from local directory: /cluster/home/user

[I 16:08:10.132 NotebookApp] 0 active kernels

[I 16:08:10.132 NotebookApp] The IPython Notebook is running at: http://localhost:8889/

[I 16:08:10.132 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

在我的本地计算机上

5) SSH 隧道

 user@local$ ssh -N -f -L localhost:8888:127.0.0.1:8889 username@remote_host

在远程主机 (/etc/hosts) 上,您会发现

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

6) 最后,我尝试在浏览器上打开 localhost:8888,结果是:

channel 2: open failed: connect failed: Connection refused

channel 2: open failed: connect failed: Connection refused

channel 2: open failed: connect failed: Connection refused

channel 2: open failed: connect failed: Connection refused

channel 2: open failed: connect failed: Connection refused

所有这些步骤在一台服务器上有效,但在另一台服务器上失败。

我尝试联系管理员并说了以下内容:

I assume that you are using two separate SSH connections: one from which you run ipython and one that you use to do port forwarding. There is no guarantee that the two connections will land you on the same login node. In the case where the two connections are on different hosts, you will experience the exact failure you have encountered. Therefore you should setup the port forwarding in the connection that you use to run ipython.

如何在用于运行 ipython 的连接中设置端口转发?

我尝试使用我的 IP 地址,但没有成功

$ ssh -N -f -L local_ip_address:8888:127.0.0.1:8889 user@remote_host

最佳答案

最后问题是这样解决的:

# Login to the server from your local workstation and in the same connection do the port forwarding.
user@local$ ssh -L 8888:localhost:8889 username@remote_host
user@remote_host$ ipython notebook --no-browser --port=8889

关于ssh - 如何远程启动IPython笔记本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31005881/

相关文章:

python - Dataframe 命令在 IPython 中有效,但在脚本中无效

python - 如何加载经过训练的 tensorflow 模型

python - Plotly 在 Jupyter 问题中

python - 标题和标签未显示在直方图中

xcode - Xcode 的 .ssh key 和 Github 帐户是否有内部配置?

github - Azure DevOps 构建子模块

python - 如何将新的默认软件包添加到virtualenv?

ipython - `get_ipython' 在 IPython/IPython Notebook 的启动脚本中不起作用...?

python - 如何将参数传递给部署脚本?

multithreading - 在Linux上通过SSH运行多线程Perl脚本的问题