是否可以使用 socat 实现以下操作,而无需使用 ssh?
> ssh -N -R 8080:localhost:1080 [email protected]
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
This works by allocating a socket to listen to port on the remote side, and whenever a connection is made to this port,
the connection is forwarded over the secure channel, and a connection is made to host port hostport from the local machine.
-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).
答案1
可能不会。虽然socat
可以将本地系统上的端口 8080 转发到远程系统上的端口 1080,但它无法改变您的原点 - 您仍将从本地系统进行连接。
使用 ssh,连接通过 ssh 隧道转发,这样当某个东西连接到远程系统的 1080 端口时,它看起来也源自该系统。如果有防火墙阻止外部访问该端口(或者如果相应的进程只在环回接口上监听),这会产生重大影响。