Windows 10 和 OpenSSH 加密本地 TCP 端口

Windows 10 和 OpenSSH 加密本地 TCP 端口

我在一台 Windows 10 机器上工作。我编写了 2 个应用程序:服务器和客户端。它们都通过标准 TCP 套接字进行通信,没有加密。我安装了 OpenSSH,目前没有证书,只有密码登录以保持简单。我不想将服务器监听端口暴露给世界其他地方,所以它监听 127.0.0.1:9000。我想配置 SSH 服务器以加密端口 9000 的流量,将其隧道传输到 9001,以便客户端可以通过加密套接字连接到服务器。我正在尝试这样做:

ssh -p 22 -N -L 9001:localhost:9000 localhost

我希望客户端能够连接到 localhost:9001,但是它却无法工作。如果我理解正确的话,隧道应该以透明的方式加密服务器和客户端之间的流量,就像服务器和客户端都没有使用加密套接字,但它们应该能够通过隧道进行通信。

sshd 的输出是

debug1: Local connections to LOCALHOST:9001 forwarded to remote address localhost:9000
debug1: Local forwarding listening on ::1 port 9001.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 9001.
debug1: channel 1: new [port listener]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Connection to port 9001 forwarding to localhost port 9000 requested.
debug1: channel 2: new [direct-tcpip]
debug1: channel 2: free: direct-tcpip: listening port 9001 for localhost port 9000, connect from 127.0.0.1 port 2408 to 127.0.0.1 port 9001, nchannels 3
debug1: Connection to port 9001 forwarding to localhost port 9000 requested.
debug1: channel 2: new [direct-tcpip]
debug1: channel 2: free: direct-tcpip: listening port 9001 for localhost port 9000, connect from 127.0.0.1 port 2411 to 127.0.0.1 port 9001, nchannels 3
debug1: Connection to port 9001 forwarding to localhost port 9000 requested.
debug1: channel 2: new [direct-tcpip]
debug1: channel 2: free: direct-tcpip: listening port 9001 for localhost port 9000, connect from 127.0.0.1 port 2413 to 127.0.0.1 port 9001, nchannels 3

如上所述,服务器没有回复。当然,如果我告诉我的客户端直接连接到端口 9000,一切都会正常。

我以前尝试过这种方法,例如访问远程机器上的 MySQL 服务器。在这种情况下,它工作得很好。

sshd_config 文件非常标准,我尝试更改一些参数(ListenAddress、AllowTCPForwarding),但没有成功。我认为这并不重要,但这两个应用程序都是用 Qt/C++ 编写的

感谢您提供的所有帮助。

相关内容