利用 SSH 端口转发访问 Jupyter Lab
通过跳板机 SSH 端口转发,访问目标服务器的 Jupyter Lab。
网络结构拓扑图
现有一台 GPU
服务器(node),与另一服务器(master)即跳板机相连。GPU
服务器未接入网络,但 master 接入网络,此时可以采用两次 SSH
端口转发访问 node 上运行的 Jupyter Lab。 
连接步骤
1 登录 master 和
node 服务器
从本地登录 master 节点 1
ssh username@master_ip
master 登录 node 节点 1
2
3ssh username@node
or
ssh nodenode 登录 master 1
2
3ssh username@master
or
ssh master1
exit
2 在 node 上运行
Jupyter Lab
设置 Jupyter 密码
1 | jupyter notebook password |
运行 Jupyter Lab 1
jupyter lab --no-browser --ip="0.0.0.0" --port=10886
1
nohup jupyter lab --no-browser --ip="0.0.0.0" --port=10886 &
3 端口转发
master 上的端口转发:master 也是无界面的
commandline 模式,因此需要转发 node 的 10886
端口。在 master
中运行以下命令,其中 xx.xx.xx.xx 是 master 的
ip(ip地址也可用localhost代替),10110 是
master 的端口,10886 是 node
的端口。 1
ssh -N -f -L 10110:xx.xx.xx.xx:10886 user@node
node 的 Jupyter Lab 可以在
master 上通过 localhost:10110
或在本地通过 xx.xx.xx.xx:10110 进行访问。出于某些原因,有时可能需要将
master 的端口再转发至本地,即 localhost
1
ssh -N -f -L 8888:localhost:10110 user@xx.xx.xx.xx
其他Linux命令
1 停止进程
若要停止 Linux 上的 SSH 端口转发或 Jupyter
Lab,可以通过 ps aux | grep (filter_name) 来查找进程,并
kill 进程。
2 SSH 连接参数
1 | -C 压缩传输 |