slm*_*slm 6 ssh remote-management ssh-tunneling
我最近在家里的内部可访问系统上设置了 FreeIPA。我想从 LAN 外部的网络管理此 Web UI,但同时,我不想将此 Web UI 暴露给公共 Internet。有没有办法通过 SSH 隧道访问它?
注意:我熟悉使用ssh
&它的-L
开关设置隧道,如下所示:
$ ssh -L 12345:ipa.local.net:80 mysshserver
Run Code Online (Sandbox Code Playgroud)
然而,这种方法在这种情况下不起作用,因为除了能够使用端口 443 和 80 访问 Web UI 之外,访问 FreeIPA 还要求您使用服务器的实际主机名。
有没有另一种方法可以实现这一目标ssh -L
?
执行 SSH 隧道可能会与所有术语混淆,但它有一个补充功能-L
,它使您能够通过在本地分配套接字而不是单个端口来“动态”分配端口。
从手册页:
-D [bind_address:]port
Specifies a local ``dynamic'' application-level port forwarding. This works by
allocating a socket to listen to port on the local side, optionally bound to the
specified bind_address. Whenever a connection is made to this port, the connection
is forwarded over the secure channel, and the application protocol is then used to
determine where to connect to from the remote machine. Currently the SOCKS4 and
SOCKS5 protocols are supported, and ssh will act as a SOCKS server. Only root
can forward privileged ports. Dynamic port forwardings can also be specified in
the configuration file.
Run Code Online (Sandbox Code Playgroud)
通过分配套接字,所有流量都可以汇集到远程站点,包括 DNS 查询。
首先,你需要像这样打开一个到你的局域网的连接(通过它在互联网上的公共 IP 地址):
$ ssh -D 1234 myserver
Run Code Online (Sandbox Code Playgroud)
注意:这假设您能够通过 SSH 连接到可通过您的公共互联网 IP 地址访问的服务器。
设置完成后,在另一个终端中,您需要配置 Web 浏览器以使用此隧道。注意:这种类型的隧道为您提供了一个套接字,因此要连接到它,您需要告诉您的 Web 浏览器通过此套接字代理其所有流量。这通常显示为代理的SOCKS 或 SOCKS v5 类型的连接。
在这个例子中,我将展示如何通过 CLI 使用 Chromium 来做到这一点:
$ ./Chromium --proxy-server="socks5://localhost:1234"
Run Code Online (Sandbox Code Playgroud)
在这里,我启动 Chromium 并将其指向我们之前在本地主机的端口 1234 上配置的 SSH 隧道。这样,如果我尝试访问在我的 LAN 上配置的服务器的 URL,我将被定向到它:
所有主要浏览器都提供此功能,并且在其他 SE 站点(例如 SuperUser)上进行了广泛的介绍:
您甚至可以使用各种浏览器的扩展程序,这些扩展程序允许您有选择地仅代理某些流量,同时允许您通过与互联网的正常连接将其他所有内容路由出去。
例如,您可以使用 ProxySwitchy!使用 Chrome 来做到这一点:
归档时间: |
|
查看次数: |
11979 次 |
最近记录: |