SSH隧道创建成功,但telnet测试仍然失败

Mal*_*ore 2 ssh-tunnel

我在 RHEL 5 系统上连接到另一个 RHEL 5 系统。我使用以下命令创建了 SSH 隧道:ssh -2 -4 -f -x -N -L 1527:remote_host:1527 user@remote_host

(remote_host是同一台服务器)

我输入密码,然后立即返回到命令提示符。我快速运行了 'ps axu | grep ssh' 来验证并查看我刚刚执行的 ssh 命令的进程:

dashbrd  17861  0.0  0.1  68796 13224 ?        Ss   12:44   0:00 ssh -2 -4 -f -x -N -L 1527:remote_host:1527 user@remote_host
Run Code Online (Sandbox Code Playgroud)

我假设我的隧道已成功建立。

然后我使用“telnet remote_host 1527”进行测试,但无法连接;在我杀死它之前会挂起几分钟。我在本地主机上尝试使用不同用户(包括我用于建立隧道的用户名)进行telnet测试,结果是相同的 - 没有连接。

此隧道的目的是连接到 Oracle 侦听器。因此,我运行tnsping实用程序;也无法连接。(是的,我在 tnsnames.ora 文件中正确配置了数据库连接。)

我做错了什么?

小智 5

您不远程登录到remote_host,而是远程登录到本地主机。如果您可以直接远程登录到remote_host,则不需要端口转发

\n\n
telnet localhost 1527\n
Run Code Online (Sandbox Code Playgroud)\n\n

从 ssh 手册页:

\n\n
\n
 -L [bind_address:]port:host:hostport\n         Specifies that the given port on the local (client) host is to be\n         forwarded to the given host and port on the remote side.  This\n         works by allocating a socket to listen to port on the local side,\n         optionally bound to the specified bind_address.  Whenever a con-\n         nection is made to this port, the connection is forwarded over\n         the secure channel, and a connection is made to host port\n         hostport from the remote machine.  Port forwardings can also be\n         specified in the configuration file.  IPv6 addresses can be spec-\n         ified with an alternative syntax:\n         [bind_address/]port/host/hostport or by enclosing the address in\n         square brackets.  Only the superuser can forward privileged\n         ports.  By default, the local port is bound in accordance with\n         the GatewayPorts setting.  However, an explicit bind_address may\n         be used to bind the connection to a specific address.  The\n         bind_address of \xe2\x80\x9clocalhost\xe2\x80\x9d indicates that the listening port be\n         bound for local use only, while an empty address or \xe2\x80\x98*\xe2\x80\x99 indicates\n         that the port should be available from all interfaces.\n
Run Code Online (Sandbox Code Playgroud)\n
\n