使用SSH创build一个虚拟主机

我有以下设置:

  • 连接到另一个networking上的VPN的本地networking上的计算机可以称为计算机A
  • 本地networking上可以访问机器A但无法访问VPN的机器。 让我们叫它机器B.

现在,如果我想从机器B访问VPN中的主机,我当然可以做ssh转发或链接的ssh调用(例如ssh machine-a ssh machine-vpn ),但是这只给我提供了有限的访问权限(即,在使用-L选项的SSH隧道中)。 有没有办法使用SSH创build某种“虚拟主机”,以便与SSH中的该虚拟主机的任何连接都将被转发到VPN内的目标主机,而不pipe端口如何? 以另一种方式提出这个问题:

从机器A:

 ssh -L 16000:machine-vpn:22 machine-a #creating the initial tunnel to the SSH port on machine-vpn #now ssh -p 16000 localhost does an SSH to the machine behind the vpn #create the Virtual Host somehow using SSH, call the virtual host vhost ssh vhost #this will ssh to the machine behind the vpn, using ssh tunnel ftp vhost #this will ftp to the machine behind the vpn, using ssh tunnel #etc. 

有没有办法做这种事情?

SSH也支持dynamic转发。 通过指定dynamic端口,ssh客户端将创build一个SOCKS5代理,然后您可以使用该代理来转发所有通信并使其从远程主机离开。

 ssh -D2000 machine-a 

您可以configuration大多数程序(浏览器和FTP等)使用袜子代理。 在这个例子中你需要做的是指向localhost:2000作为SOCKS代理。

查看最近版本的OpenSSH中的TunnelTunnelDevice选项。