ssh tunnel

空扰寡人 提交于 2020-03-04 23:49:23
server  A B C D
<A>   <B>   <C>   <D>
-   Local -- Forward local port to remote host.
-   Remote -- Forward remote port to local host.
-   Dynamic -- Use SOCKS.

#---------------------------------------------------------------
<A>$ ssh  -L  8888:<C>:22  root@<B>
<A> 打开本地8888端口,访问<A>的8888端口,实现通过 <B> 跳转到<C>的22端口

#-----------------------------------------------------------------
<B> sshd_config
  GatewayPorts no  # 不允许外部访问<B>
  GatewayPorts yes   # 允许外部访问<B>的端口
  GatewayPorts clientspecified  # 指定被允许的外部IP

<C>$ ssh -R 8888:localhost:22 root@<B>
<A>访问<B>的8888端口,实现通过 <B> 跳转到<C>的22端口

<C>$ ssh -R 8888:<D>:22 root@<B>
<A>访问<B>的8888端口,实现通过 <B> 跳转到<D>的22端口

#--------------------------------
SOCKS:Specifies a local ``dynamic'' application-level port forwarding
<B>$ ssh -D 0.0.0.0:8888 root@<C>
<A>通过<B>的8888端口使用<C>作为代理

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!