AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 544378
Accepted
Alexis Wilke
Alexis Wilke
Asked: 2019-09-30 15:27:06 +0800 CST2019-09-30 15:27:06 +0800 CST 2019-09-30 15:27:06 +0800 CST

我需要什么来创建到远程主机上运行的本地网络服务的 SSH 隧道?

  • 772

我想将 virtualbox 计算机连接到远程计算机上的本地服务。我可以连接到本地服务,但是远程服务有问题,因为在目的地,服务在本地 LAN 中运行。

这是第三台计算机和第三台计算机上的两个接口的图形。我想连接到 10.0.0.8:200,因为我想连接的服务只在远程计算机上的本地网络上运行。

+--------------------+
|                    |
|  VirtualBox        |
|  192.168.11.11:200 |
|                    |
+-----+--------------+
      |
      v
+--------------------+
|                    |
|  Local Computer    |
|  192.168.11.41:200 |
|                    |
+-----+--------------+
      |
      v
+--------------------+
|                    |
|  Remote Computer   |
|  8.8.8.8           |    <- I can connect here
|                    |
|  10.0.0.8:200      |    <- how do I connect here?
|                    |
+--------------------+

我可以在本地计算机和远程计算机之间打开一条隧道,但这并不能让我连接到本地网络 10.0.0.8 上的服务。

到目前为止,我所拥有的是本地计算机和远程计算机之间的 SSH 隧道。否则,我可以在 VirtualBox 和本地计算机之间进行连接(我有一个桥接网络设置,可以按预期工作。)

ssh -L 200:8.8.8.8:200 example.com

所以我缺少的是 8.8.8.8 和 10.0.0.8 之间的连接。如何在两者之间创建一个隧道/代理,使我的本地计算机可以使用 10.0.0.8:200 上的服务?

ssh
  • 1 1 个回答
  • 1074 Views

1 个回答

  • Voted
  1. Best Answer
    SparedWhisle
    2019-09-30T16:31:07+08:002019-09-30T16:31:07+08:00

    首先,您的命令中有一个明显的错误。您的程序仅在本地网络上运行,但您使用 .将连接转发到公共 IP -L 200:8.8.8.8:200。所以你应该-L 200:10.0.0.8:200改用。

    其次,通过使用-L 200:10.0.0.8:299,ssh 客户端默认只会监听localhost:200。可以使用该GatewayPorts选项配置此行为。要明确告诉 ssh 客户端接受来自其他主机的连接,您可以使用-L 0.0.0.0:10.0.0.8:200. 来自man ssh_config:

         GatewayPorts
                 Specifies whether remote hosts are allowed to connect to local forwarded ports.  By default, ssh(1) binds local port forwardings to the loopback address.  This
                 prevents other remote hosts from connecting to forwarded ports.  GatewayPorts can be used to specify that ssh should bind local port forwardings to the wild‐
                 card address, thus allowing remote hosts to connect to forwarded ports.  The argument must be yes or no (the default).
    
    
    • 2

相关问题

  • 为什么 ssh 实用程序被视为 pty?

  • Auto-SSH 手动工作,但不在后台工作

  • 远程运行 X 应用程序,在远程主机上运行 GUI [关闭]

  • rsync 端口 22 和 873 使用

  • SCP突然中止:管道损坏,消息验证码不正确

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve