两步ssh隧道的Jupyter Notebook SSH隧道 [英] Jupyter notebook SSH tunnel for two step ssh tunnel

查看:110
本文介绍了两步ssh隧道的Jupyter Notebook SSH隧道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过SSH隧道访问jupyter笔记本,并遵循此食谱

I want to access a jupyter notebook via an SSH tunnel and follow this recipe

https://hsaghir.github.io/data_science/jupyter-notebook-on-a-remote-machine-linux/

总结-: 1.登录远程计算机

To sumarize - : 1. Log in remote machine

user@local_host$ ssh user@remote_host

remote_user@remote_host$ jupyter notebook --no-browser --port=8889

2.在新终端中:

user@local_host$ ssh -N -L localhost:8888:localhost:8889 remote_user@remote_host

3.然后转到浏览器并转到

3.Then go to a browser and go to

localhost:8888


现在这是我的问题: 我只能通过两个步骤访问远程机器


Now here is my problem: I can access the remote machine only in two steps

ssh -X username@server

ssh -KX my_pc_name

并且jupyter笔记本仅安装在my_pc_name上.

and the jupyter notebook is only installed on my_pc_name.

当我用较长的登录过程替换第一步的第一行时,该为第二步写什么?

What do I write for the second step, when I replace the first line of the first step by my longer log in procedure ?

当我插入电源时 remote_user =用户名和remote_user = my_pc_name ,我从jupyter笔记本电脑获取令牌时遇到安全错误.我从第一步运行的jupyter笔记本获得的令牌不起作用.

When I plug in remote_user = username and remote_user = my_pc_name, I get an security error from the jupyter notebook asking for a token. The token that I get from step one, running the jupyter notebook will not work.

一种解决方案是将两个ssh日志逐步合并为一个.

One solution could be to combine the two ssh log in steps to one.

推荐答案

似乎服务器"是您的网关服务器,并且只能从那里访问"my_pc_name".尝试像这样建立两个连接的ssh隧道:

It seems 'server' is your gateway server, and that 'my_pc_name' is accessible only from there. Try establishing two connected ssh tunnels like so:

所以我会这样做.打开终端并运行:

So I would do this. Open a terminal and run:

ssh -f username@server -L 8888:localhost:8889 -N

这会将您的本地计算机连接到跳转服务器并进行端口转发.

This connects your local machine to the jump server and does port forwarding.

然后打开一个新终端并运行:

Then open a new terminal and run:

ssh username@server
ssh -f my_pc_name -L 8889:localhost:8889 -N -K

这应该将您连接到跳转服务器,并在跳转服务器和my_pc_name之间进行端口转发.

This should connect you to the jump server and do port forwarding between jump server and my_pc_name.

然后打开另一个终端并运行:

Then open another terminal and run:

ssh -X username@server
ssh -KX my_pc_name
jupyter notebook --no-browser --port=8889

这将使您连接到my_pc_name并在其中运行jupyter笔记本服务器.

This should connect you to my_pc_name and run the jupyter notebook server there.

最后转到本地计算机上的浏览器并访问: localhost:8888

Finally go to your browser on your local machine and access: localhost:8888

您的ssh连接字符串中确实有-X选项,它表示X11窗口(Linux的一种远程桌面).尝试删除它,看看它是否仍然有效,否则您可能必须保留它.另外,-K表示转发Kerberos票证,您可能需要允许它访问文件,因此我保留了它.

You do have the -X option in your ssh connection string, which indicates X11 windowing (a type of remote desktop for linux). Try dropping it and see if it still works, else you may have to keep it. Also, -K indicates forwarding of Kerberos tickets, which you probably need to allow file access, so I kept it.

您可能必须在计算机上同时使用这些功能才能使它正常工作.

You may have to play with a combination of these on your machine to get it working.

这篇关于两步ssh隧道的Jupyter Notebook SSH隧道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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