VNC over SSH on a reversible tunnel


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users VNC over SSH on a reversible tunnel
# 1  
Old 01-16-2012
Question VNC over SSH on a reversible tunnel

Hi there,

I have a situation in which one of my client have a few computers (MS Windows) behind a non routable box. They also have a tiny server (Debian).

Because the box is non routable, I cannot create any port forwarding :
  • neither on port 22 to the Debian server
  • nor on port 590X to each individual MS Windows client with TightVNC server.
I solved the problem of administrating the server remotely by creating a reversible tunnel from their Debian server to mine.
Note: The SSH tunnel is not continuously open. There's a cron job that checks every 5 minutes if I need to connect (because I create a file with a set name) and therefore create the reversible tunnel.

My second issue is the following. I read (and tried to understand) that one can create a TightVNC connection over an SSH tunnel. And I'm thinking :
Would it be possible to create a reversible tunnel from my customer's Debian server to my Debian server and use this tunnel to do VNC from my MS Windows workstation to my customer's MS Windows workstation ?

Image

Sounds weird hey?
Well let's not be afraid to ask...
Is there anything I can do close to this fantasy?

Thanks for your ideas.
Santiago
# 2  
Old 01-16-2012
How I would fix this issue would be by hosting a VPN on your debian server, and having the custom one connect to it. We use OpenVPN in this fashion (and in routing mode) to communicate with many servers behind NAT. All you need is to open one port on your internet router, the routable one, so that remote VPN clients can connect to it.

Connecting over VPN makes them part of an entirely new virtual network. What this does for us is creates a 172.16.x.x network branch between the server and the client(s), and a new IP address in the 172.16.x.x range for each client, which we can connect to them over with ssh. The VPN driver translates this into activity over the VPN connection itself.

Then you can just host whatever you want, and connect to the virtual IP's, without having to do torturous things to get a connection through.

Last edited by Corona688; 01-16-2012 at 04:43 PM..
# 3  
Old 01-19-2012
Hi Corona688,

And thanks so much for the idea. It sounds fantastic!
I'm now thinking of using this idea on a standard basis with all my clients.
I tried to get started with VPN in general.
And if I understand well, I can create sort of a global private network among all my customer's offices and mine. All controled by a VPN server that I'll choose to host public rather than behind my box.

Image

I got a few questions if you don't mind:

The public VPN server.
  • I will host it on a dedicated server at OVH.
  • It will have a public IP address (say 83.84.85.86).
  • Does it need to have a second NIC for the VPN address or is it just a setting in the service configuration.
  • Can I set it to route all traffic between my office and my customers and to route all traffic between my customers and me but not between my custmers?

All the network boxes.
  • If I understand well, there's nothing I need to configure given that the connection will be outgoing (from each network server to the VPN server). Is that correct?

All the network Debian servers.
  • I will install OpenVPN and set it to connect to the VPN server (83.84.85.86). That's it?
  • They usually just have one NIC. Do I just need to set them with a VPN compatible IP address?
  • At that point, will my Debian server be able to SSH connect to any client Debian server ?

All the network workstations.
  • I'd like to not set anything there. Just DHCP.
  • If I tell them the gateway is their local Debian server. And then if I tell the server to route requests through the VPN.
  • Will all the workstation look like they are in the same network?

This project seems very exciting!
I can't wait for another hint!
I know it's a lot of questions to ask so don't feel pressured and just answer whatever you have time for.

Thank you SOO much for your brilliant idea.

Santiago
# 4  
Old 01-19-2012
Quote:
Originally Posted by chebarbudo
I got a few questions if you don't mind:

The public VPN server.[LIST][*]I will host it on a dedicated server at OVH.[*]It will have a public IP address (say 83.84.85.86).[*]Does it need to have a second NIC for the VPN address or is it just a setting in the service configuration.
It doesn't need another real network card to work, though it does need a (fairly standard) kernel module, the "universal tun/tap" device driver (modprobe tun). That allows openvpn to create a 'tun0' network interface for it to funnel traffic through.

These tun devices are real as far as the kernel's concerned. It shows up in ifconfig and /sys/class/net, has an IP address, gets routed, and all of that. But its traffic doesn't come from a cable, it comes from openvpn.

Your remote clients would keep TCP connections open to your central server at all times. This one socket is enough to tunnel everything OpenVPN needs to act like an entire network, including connections in both directions. Traffic gets encoded and encrypted and sent across this socket where the other end decrypts and decodes it, then crams it in the tun device to turn it into an actual network request.

Quote:
Can I set it to route all traffic between my office and my customers and to route all traffic between my customers and me but not between my custmers?
Sure you can divert traffic through it, just like you'd divert traffic through anything else. So probably not as easy as you were hoping.

It's not a networking override, it's just there, like any other network device is. It acts like an extra network device on your computer, plugged into a imaginary and private switch that's shared by all your VPN clients. Hence, "Virtual Private Network".
Quote:
If I understand well, there's nothing I need to configure given that the connection will be outgoing (from each network server to the VPN server). Is that correct?
Networking-wise, the only thing your remote servers need is the ability to connect to your central server over TCP on port 1194. If they can do that, OpenVPN can operate.

They also need to be told what server to connect to, what keys to use and a few other small details. OpenVPN has a setup guide that is very straightforward for UNIX systems.

Quote:
I will install OpenVPN and set it to connect to the VPN server (83.84.85.86). That's it?
You have to set up some sort of authentication. I use static keys, myself, but there's other ways. The quick start guide shows you how.
Quote:
They usually just have one NIC. Do I just need to set them with a VPN compatible IP address?
You don't need another network card. OpenVPN uses traffic across your normal network interface to control a completely new, independent network interface. It will have its own IP address that only your VPN server and (optionally) other VPN clients can talk to.

It acts completely real. You could host an apache server on your VPN address, say, 172.16.0.22, and only things on the VPN could reach it.
Quote:
At that point, will my Debian server be able to SSH connect to any client Debian server?
Yes, though you'll need to ssh into their VPN IP addresses, not their physical IP addresses. OpenVPN will take care of the rest.
Quote:
I'd like to not set anything there. Just DHCP.
OpenVPN comes with that by default, your VPN server will auto-assign private IP's in the range you gave it to your VPN clients.

Quote:
If I tell them the gateway is their local Debian server.
You can't route all traffic, remember? The VPN traffic itself, at least, needs to be real.

But the clients should be able to talk to each other across the VPN as if directly connected. You should be able to redirect traffic into the VPN with iptables, or set your VPN server's VPN IP as their HTTP proxy, or whatever you'd be able to do if you ran 9-mile cables between all your clients to get them on the same physical switch.

---------- Post updated at 01:50 PM ---------- Previous update was at 01:40 PM ----------

I'll try explaining in less detail how it'd work.

It's like giving your server and clients an extra "tun0" network card, assigning these cards 10.x.x.x addresses, and running long enough cables to physically connect these cards all to your server. What you do with those cables is wholly up to you -- it's just another network.

But tun0 is not a real network card, just a device driver. Kernel trickery converts traffic into tun0, to bytes read by openvpn; the same kernel trickery converts bytes written by openvpn into "real" requests emerging from tun0. Inbetween the two, all the data -- including everything needed to make connections in both directions -- is bundled through one single TCP connection on port 1194. Your real network must keep running uninterrupted for tun0 to function.

I should point out that it has some limits. In its usual mode of operation it handles pure IP traffic, so you get TCP and UDP and ping, as well as any service you could connect to TCP over. You can't put SMB, ARP, BOOTP, or other non-IP things through it. Broadcast traffic also doesn't work.

It also has a bridged mode, which can tunnel nearly anything, but that's complicated, tricky, and slow, so I don't recommend it.

Last edited by Corona688; 01-19-2012 at 04:10 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Tunnel using SSH

I am not clear with the part of concept of Tunneling using ssh. ssh -f -N -L 1029 192.168.1.47:25 james@192.168.1.47 I found out that above code works for me . but didn't quite well understood how ti works and need to ask you guys some questions. since we are using tunnel through ssh ... (2 Replies)
Discussion started by: lobsang
2 Replies

2. Solaris

Tunnel X over ssh for 11.3

Hello Solaris experts: Trying to bring the 11.3 gdm screen over ssh to a Linux Box: I did the following: 1. made chanes to /etc/ssh/sshd_config & bounced ssh daemon: # X11 tunneling options X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes 2. From the remote Linux box: ... (6 Replies)
Discussion started by: delphys
6 Replies

3. Proxy Server

WebSocket over SSH tunnel - is it possible?

Hello, I have a video streaming application that utilizes a WebSocket for the server <-> client communication. My goal is to make the video streaming service available over the internet in the cases where neither the server nor client have public IPs. One way to do this is over a VPN... (8 Replies)
Discussion started by: Vladislav
8 Replies

4. UNIX for Advanced & Expert Users

Ssh tunnel question

Hi all I have a suite of scripts that ssh to remote servers within a cluster and run some tests. This is done from a central server so that all of the test results can be captured in one location. Problem is I now have 509 tests and the number is growing. The scripts work by establishing a... (2 Replies)
Discussion started by: steadyonabix
2 Replies

5. IP Networking

Help with SSH tunnel?

I have a Java web app on machine (X) that needs to talk to an LDAP server (Y) on :636, but the LDAP server is only accessible on a particular network. I can login to a machine (Z) on that network from X, and this machine can talk to the LDAP server on :636. How can I tunnel so that X can... (2 Replies)
Discussion started by: spacegoose
2 Replies

6. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

7. Cybersecurity

RDP over SSH Tunnel

Hi all, I'm trying have an alternative way of connecting into a Corporate network. Mostly in case the VPN down as I cannot also change the security policy. I want to expose windows RDP over ssh tunnel. I have 3 hosts in my scenario 1- Host a : Windows 2k8 has no internet access just only an... (3 Replies)
Discussion started by: h@foorsa.biz
3 Replies

8. UNIX for Advanced & Expert Users

Stopping SSH tunnel

I have initiated a tunnel for vncserver. now i want to stop it. is there any way except sleep option? (2 Replies)
Discussion started by: majid.merkava
2 Replies

9. UNIX for Advanced & Expert Users

ssh decipher a tunnel

Two question here, but it's only one on the protocol point of view. If two persons use the same key to connect to a SSH server is there a risk they can decipher the other tunnel. In other terms is that less safe than if they have two separate keys. Same question if two persons use the same user... (2 Replies)
Discussion started by: moi
2 Replies

10. UNIX for Dummies Questions & Answers

vnc over an ssh tunnel Linux to Linux to Windows

I *think* what I want to do is not only possible but easy, but as a "dummy" :) I can't figure it out. Here's what I have: Linux (Ubuntu 10.04) laptop that is not in my house, but has an Internet connection. Linux (Ubuntu 9.04) computer in my house that has unfettered access to the... (6 Replies)
Discussion started by: WesleyC
6 Replies
Login or Register to Ask a Question