远程访问 WSL2 Jupyter notebook [英] Access WSL2 Jupyter notebook remotely

查看:115
本文介绍了远程访问 WSL2 Jupyter notebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图从远程电脑连接到我的 jupyter 笔记本,因为我自己的电脑没有全局 IP 我必须首先连接到本地网络中的另一台电脑(服务器 1),然后 ssh 到我自己的电脑上运行 jupyter(服务器 2)所以它是这样的:

So I'm trying to connect to my jupyter notebook from a remote pc, since my own pc doesn't have a global IP I have to first connect to another pc in the local network(server 1) and then ssh to my own pc with jupyter running on it(server 2) so its something like this:

我的笔记本电脑 ->服务器 1 ->服务器 2

my laptop -> server 1 -> server 2

当两台服务器都是这样的 Linux 时,我曾经这样做过:

I used to do this when both servers were Linux like this:

在我的笔记本电脑上:ssh -NL 2323:localhost:2323 server1_username@golbalIp

在服务器 1 上:ssh -NL localhost:2323:localhost:8888 server2_username@localip

在服务器 2 上:python3 -m jupyterlab --NotebookApp.token='' --NotebookApp.password='' --port 8888

但现在我的服务器 2 是一台 Windows pc,我的 jupyter 在 wls2 上,所以我想,因为在 Windows 的 localhost:8888 上运行 wsl2 的 jupyter 然后做同样的事情会起作用但它没有,我该如何解决这个问题?

but now my server 2 is a windows pc and my jupyter is on wls2, so I figured since on windows' localhost:8888 runs wsl2's jupyter then doing the same thing would work but it doesn't, How can I fix this?

推荐答案

这不是很明显,但解决方案是 Windows 10 不喜欢端口 8888,需要您使用 8889 才能使端口转发在 WSL2 上工作.我花了很长时间才解决这个问题.在原生 linux 下,端口完全没有问题,除非远程主机有特定的自定义防火墙规则.

Its not at all obvious, but the solution is that Windows 10 does not like port 8888 and requires you to use 8889 to get the port forwarding to work on WSL2. Took me a long time to work this out. Under native linux there is no issue at all with port, unless the remote host has specific customised firewall rules.

所以你必须使用:

 ssh -NL 8889:localhost:8888 remote-server-alias

其中 remote-server-alias 是您在 .ssh/config 中使用 JumpProxy 定义的内容,并且您还必须让 apache2 服务器在 Windows (WSL2) 安装(例如)上运行在 Debian 上.首先在浏览器中检查localhost,确保apache服务器运行正常.

where remote-server-alias is something you have defined in your .ssh/config with JumpProxy and you must also have your apache2 server running on your Debian on Windows (WSL2) installation (for example). Check localhost in a browser first to ensure that the apache server is running correctly.

在开始之前,您必须执行以下操作:

Before you begin you must do the following:

ssh remote-server-alias
nohup jupyter notebook --no-browser --port 8888 &

令牌会为您存储在 nohup.out 中.

The token will be stored for you in nohup.out.

这篇关于远程访问 WSL2 Jupyter notebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆