通过VNC的笔记本电脑从防火墙后面隧道到远程服务器?

时间:2017-11-21 21:50:19

标签: linux networking ssh firewall

我在linux上有一个命令行应用程序,它使用特定端口与远程服务器通信。不幸的是,在工作中,该端口被阻止。

我可以通过VNC将笔记本电脑连接到网络,笔记本电脑处于wifi连接状态, 可以通过端口访问远程服务器。我可以在连接时从安全网络ssh到我的笔记本电脑。

有没有办法使用ssh端口隧道来解决这个问题?我可以将隧道移植到笔记本电脑上,让我的笔记本电脑充当防火墙网络和远程服务器之间的中间人吗?

非常感谢。

1 个答案:

答案 0 :(得分:0)

如果我理解你的错误,你可以从你到达笔记本电脑的地方拨打ssh。然后你应该可以做这样的事情:

ssh -f -N -L <local port>:<remote server ip or hostname>:<remote server port> <laptop ip or hostname>

这将在主机上创建启动tcp侦听端口,其中ssh始发,通过您运行的计算机转发到远程主机和端口。

摘自https://man.openbsd.org/ssh

-L [bind_address:]port:host:hostport
-L [bind_address:]port:remote_socket
-L local_socket:host:hostport
-L local_socket:remote_socket
Specifies that connections to the given TCP port or Unix socket on the local
(client) host are to be forwarded to the given host and port, or Unix
socket, on the remote side. This works by allocating a socket to listen to
either a TCP port on the local side, optionally bound to the specified
bind_address, or to a Unix socket. Whenever a connection is made to the
local port or socket, the connection is forwarded over the secure channel,
and a connection is made to either host port hostport, or the Unix socket
remote_socket, from the remote machine.
Port forwardings can also be specified in the configuration file. Only the
superuser can forward privileged ports. IPv6 addresses can be specified by
enclosing the address in square brackets.
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.

-f
Requests ssh to go to background just before command execution. This is
useful if ssh is going to ask for passwords or passphrases, but the user
wants it in the background. This implies -n. The recommended way to start
X11 programs at a remote site is with something like ssh -f host xterm.
If the ExitOnForwardFailure configuration option is set to “yes”, then a
client started with -f will wait for all remote port forwards to be
successfully established before placing itself in the background.

-N
Do not execute a remote command. This is useful for just forwarding ports.