首页 > 解决方案 > 通过隧道连接(通过 ssh)连接 jupyter python

问题描述

我在连接到我在远程计算机上运行的 jupyter 时遇到问题。我已经使用 ssl 配置了 jupyter,如下面的文档所示:

https://jupyter-notebook.readthedocs.io/en/latest/public_server.html#hashed-pw

然后我使用命令在远程机器上运行 jupyter:jupyter notebook如教程中所示。当它运行时,我通过运行命令在另一个终端中建立隧道:

ssh -N -f -L 8889:127.0.0.1:8881 user_name@hostname.com

当然,jupyter 正在运行port 8881。当我在本地计算机上打开浏览器并尝试打开页面时:

localhost:8889

我收到连接已重置的错误,并且在命令行中 ssh 返回以下错误:

channel 2: open failed: connect failed: Connection refused

谁能帮我?我整天都在寻找答案,但仍然无法解决。

标签: pythonjupyter-notebookjupyter

解决方案


问题是,在我的情况下,jupyter 正在本地主机上运行。在我的服务器远程服务器上,我无法访问远程本地主机,因此解决方案非常简单 - 我在指定的 ip = 0.0.0.0 上运行 jupyter

jupyter notebook --no-browser --port=8881 --ip=0.0.0.0

推荐阅读