通过ssh隧道远程运行ipython笔记本 [英] run ipython notebook remotely through ssh tunneling

查看:60
本文介绍了通过ssh隧道远程运行ipython笔记本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否可以通过ssh两次远程使用ipython Notebook.场景是:机器B是我要运行ipython Notebook的机器.但是,只允许我首先通过另一个服务器(机器A)访问机器B.有一些关于远程使用ipython Notebook的教程,但是都没有提到我遇到的情况.

I am wondering if I can use ipython notebook remotely by ssh twice. The scenario is: Machine B is the machine I want to run ipython notebook. However, I am only allowed to access machine B through another server (machine A) first. There are tutorials about using ipython notebook remotely, but none of them mentions the situation I've encountered.

提前谢谢!

推荐答案

假设您指的是ssh隧道传输,并且ipython笔记本在服务器B的端口1234上进行服务器存储:

Assuming you are referring to ssh tunnelling, and the ipython notebook is servering on port 1234 on machine B:

如果机器A可以在任何端口上访问机器B,则可以将机器A设置为通过SSH将远程端口转发给您:

If machine A can access machine B on any port, you can setup machine A to forward a remote port to you via SSH:

ssh -L 9999:machineB.com:1234 -N machineA.com

这是

ssh到machineA.com,而不执行远程命令(-N)并设置机器A通过ssh隧道将来自客户端端口9999的请求通过ssh隧道转发到机器B端口1234

ssh to machineA.com without executing a remote command (-N) and setup machine A to forward requests from client port 9999, over an ssh tunnel, to machine B port 1234

但是,如果机器A只能通过ssh访问机器B,那么您将需要创建两个隧道.一个从客户端PC到machineA,另一个从machineA到machineB.为此,这两个隧道连接到machineA上的本地端口而不是远程端口:

However if machine A can only access machine B via ssh, then you will need to create two tunnels. One from your client PC to machineA, and another from machineA to machineB. To do this, the two tunnels connect to a local port on machineA instead of a remote port:

ssh -L 9999:localhost:8888 machineA.com ssh -L 8888:localhost:1234 -N machineB.com

这是

ssh到machineA.com并设置机器A,以通过ssh隧道将来自客户端PC端口9999的请求转发到机器A端口8888.然后执行命令"ssh -L 8888:localhost:1234 -N machineB.com".此命令设置了从machineA端口8888到machineB端口1234(iPython正在监听的端口)的第二条隧道.

ssh to machineA.com and setup machine A to forward requests from our client PC port 9999, over an ssh tunnel, to machine A port 8888. Then execute the command "ssh -L 8888:localhost:1234 -N machineB.com". This command sets up a second tunnel from machineA port 8888 to machineB port 1234 (where iPython is listening).

现在,在后台运行该命令的情况下,连接到本地PC端口9999.第一个ssh隧道会将该请求转发到连接到localhost:8888的machineA,第二个ssh隧道随后将其转发到machineB它连接到localhost:1234.

Now, with that command running in the background, connect to your local PC port 9999. The first ssh tunnel will forward that request to machineA where it connects to localhost:8888, the second ssh tunnel will then forward it to machineB where it connects to localhost:1234.

请注意,计算机A必须能够自动连接到计算机B(使用公共/专用密钥身份验证),才能在单个命令中工作.

Note that machineA will need to be able to connect to machineB automatically (using public/private key authentication) for this to work in a single command.

这是一篇很好地解释ssh隧道的文章 https://superuser.com/questions/96489/ssh-tunnel-via-multiple-hops

Here is a post that explains ssh tunnelling nicely https://superuser.com/questions/96489/ssh-tunnel-via-multiple-hops

这篇关于通过ssh隧道远程运行ipython笔记本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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