如何通过 ssh 隧道链(双隧道,公司网络中的服务器)连接到 Oracle Database 11g 服务器?

我可以通过 SSH 访问公共"服务器,这也是通往公司网络的网关.网络中有另一台服务器,本地 Oracle 数据库服务器正在运行(没有来自该服务器外部的访问,只接受本地主机数据库连接).当然,我还有另一个 SSH 访问此服务器的权限.

I have SSH access to 'public' server, which is also the gateway to company network. There is another server in the network, where local Oracle Database server is running (There is no access from outside of this server, only localhost DB connections are accepted). And of course, I have another SSH access to this server.

有没有办法从网络外部加入这个 Oracle Database 11g 服务器?我在问是否有类似 ssh 隧道链的东西,以及我如何配置它.例如,这对于 TOAD for Oracle(ORACLE 客户端)很有用.

Is there any way to join to this Oracle Database 11g Server from outside of the network ? I am asking if there is something like ssh tunnel chain, and how i configure it. This can be usefull, for example, for TOAD for Oracle (ORACLE client).

这是图片

谢谢

推荐答案

是的,这是可能的.例如.在 Linux 上,运行

Yes, it's possible. E.g. on Linux, run

ssh -N -Llocalport:dbserver:dbport yourname@connectionserver

哪里

  • localport 是你机器上将被转发的端口(如果没有运行oracle的本地实例,可以是1521)
  • dbserver 是数据库服务器的名称或 IP
  • dbport 是数据库的端口(通常是 1521)
  • 你的名字是连接服务器上的登录名
  • connectionserver 是您具有 ssh 访问权限的机器

同样可以在 Windows 上使用 Plink(Putty 附带)来完成:

The same can be done on Windows using Plink (which comes with Putty):

plink -N -L localport:dbserver:dbport yourname@connectionserver

在两台机器(您的本地机器和您有权访问的服务器)上执行此操作以链接 ssh 隧道.示例:

Do this on both machines (your local machine and the server you have access to) to chain the ssh tunnels. Example:

连接服务器(假设为 Linux):

Connection server (assuming Linux):

ssh -N -L1521:dbserver:1521 dblogin@dbserver

您的电脑:

plink -N -L 1521:connectionserver:1521 connlogin@connectionserver

tnsnames.ora 条目必须看起来像您正在运行本地数据库,例如

The tnsnames.ora entry must look like you are running a local database, e.g.

prodoverssh =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = prod)
    )
  )

相关文章