SSH隧道创build成功,但telnettesting仍然失败

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

(remote_host是同一台服务器)

我input密码,然后立即返回到命令提示符。 我运行一个快速'ps axu | grep ssh“来validation并查看我刚刚执行的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 

我假设我的隧道成功build立了。

然后我testing使用“telnet remote_host 1527”,但无法连接; 只是挂了几分钟,然后我杀了它。 我尝试用本地主机上的不同用户进行telnettesting(包括我用来build立隧道的用户名),结果是一样的 – 没有连接。

这个隧道的目的是连接到一个Oracle Listener。 所以我运行了tnsping工具。 也无法连接。 (是的,我已经在tnsnames.ora文件中正确configuration了数据库连接。)

我做错了什么?

你不telnet到remote_host,你telnet到本地主机。 如果可以直接telnet到remote_host,则不需要端口转发

 telnet localhost 1527 

从ssh手册页:

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