VNC-соединение: обход брандмауэра с использованием VPS

1333
user1419674

У меня есть друг, который живет далеко и нуждается в технической поддержке. До сих пор я не смог диагностировать проблему по телефону, поэтому я искал возможность использовать соединение VNC для удаленного устранения неполадок с его компьютером. У нас обоих есть Маки.

Проблема в том, что он находится за брандмауэром, и все порты отфильтрованы (проверено с помощью nmap). Так как я тоже за брандмауэром, мне было интересно, можно ли установить какое-либо переадресационное соединение с моим Linode VPS. то есть мы оба подключались бы к моему VPS, и весь мой VNC-трафик передавался бы через VPS на компьютер моего друга (и поскольку мы оба инициировали подключения к VPS, проблем с брандмауэрами не возникало).

1

1 ответ на вопрос

1
EightBitTony

You need a reverse SSH tunnel, and a regular SSH tunnel, and you join them together in the middle.

We have 3 machines. Friend, Server, Mac.

From Friend, you connect to Server using SSH, setting up a tunnel in the reverse direction.

ssh -R 9999:localhost:5900 user@Server

This creates an ssh session from Friend, to Server. On Server it listens on port 9999 (on the localhost address), and forwards anything on that port, back to Friend on port 5900 (through the ssh tunnel, so the firewall doesn't block it).

On Friend, you now need to ensure there's a VNC server listening on port 5900 (this is the default port for VNC servers).

Then, from Mac, you do this,

ssh -L 9999:localhost:9999 user@Server

That tunnels everything on port 9999 at your end, to port 9999 on the localhost on Server. Since 9999 on Server is then forwarded to Friend, you've joined the tunnels together.

Now, you can open a VNC Client on Mac, and connect it to port 9999 (i.e. when it asks what to connect to, you connect to 127.0.0.1:9999).

The ssh daemon on Server needs to support port forwarding for this to work.

You can do this with only one tunnel (the reverse tunnel from Friend using a slightly different format), but that leaves the Friend computer at risk because it would allow anyone to VNC to Friend by connecting to the port on Server's public IP address. This way, only you can connect.

Этот ответ был идеальным. Спасибо! user1419674 10 лет назад 0
Хорошо. Я также хотел бы отметить, что при использовании одного туннеля вам необходимо указать ** bind_address ** (возможно, включить ** GatewayPorts **), поскольку пересылка по умолчанию ограничена интерфейсом обратной связи. doc 8 лет назад 0

Похожие вопросы