ssh外网透传

查看计算节点ip

[xxxx@compute-0-4 ~]$ ifconfig
enp13s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.1.250  netmask 255.255.255.0  broadcast 10.1.1.255
        ether fc:aa:14:f3:2c:7e  txqueuelen 1000  (Ethernet)
        RX packets 1199456446  bytes 1678434692412 (1.5 TiB)
        RX errors 0  dropped 272772  overruns 940  frame 0
        TX packets 396837618  bytes 371680298623 (346.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xc7120000-c713ffff

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 15441009  bytes 3801577447 (3.5 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15441009  bytes 3801577447 (3.5 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

启动你要运行的web服务

例如,使用jupyter,把ip设置为上面ifconfig得到的ip,port自己随便设但不要和别的服务重了

[xxx@compute-0-4 ~]$ jupyter-lab --ip 10.1.1.250 --port 8887
[I 02:25:39.274 LabApp] Writing notebook server cookie secret to /run/user/1015/jupyter/notebook_cookie_secret
[I 02:25:41.139 LabApp] JupyterLab beta preview extension loaded from /share/apps/anaconda3/lib/python3.6/site-packages/jupyterlab
[I 02:25:41.140 LabApp] JupyterLab application directory is /share/apps/anaconda3/share/jupyter/lab
[I 02:25:41.146 LabApp] Serving notebooks from local directory: /home/huguanghao2
[I 02:25:41.147 LabApp] 0 active kernels
[I 02:25:41.147 LabApp] The Jupyter Notebook is running at:
[I 02:25:41.147 LabApp] http://10.1.1.250:2512/
[I 02:25:41.147 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 02:25:41.147 LabApp] No web browser found: could not locate runnable browser.

管理节点使用ssh -L 把计算节点的web服务端口也就是8887透传出去

ssh -L 管理节点ip(外网可以ping通的):(服务端口号):(计算节点ip):(端口号) 用户名@(计算节点ip)

[xxx@wuxi ~]$ ssh -L 172.18.65.18:8887:10.1.1.250:8887 xxx@10.1.1.250
Last login: Fri Dec 21 02:24:22 2018 from wuxi.local
Rocks Compute Node
Rocks 7.0 (Manzanita)
Profile built 16:05 15-Nov-2018

Kickstarted 03:15 15-Nov-2018

然后就ok了

image

image

ssh太强大了,-L就是端口转发的

参考文章_1

参考文章_2

参考文章_3