且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-01-20 07:37:33

是的,这是可能的.例如.在 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)
    )
  )