Jump to content

Ssh Tunnel Connecting 2 Remotes For Vnc


Recommended Posts

After watching the latest episode on SSH tunneling I've been trying to work out how to route VNC traffic from one computer to another through a server in the middle. Darren's walk-through only covered a point-to-point connection Here is a copy/paste from a post that I made on Amazon's EC2 forum:

Ok, I'm trying to connect 2 computers using VNC via tunneling on an EC2 server running Ubuntu 12.04 server. Here's the layout:

Computer 1 <-------> EC2 Server <--------> Computer 2

Computer 2 is running a VNC server on port 5900

Computer 1 is running a VNC client

I think that tunneling the traffic via SSH is the right solution in this situation, so here's what I've got so far

Computer 2 connects to the EC2 using:

ssh -L 5900:localhost:5555 ubuntu@ec2serveraddress.com

Computer 1 connects to EC2 using:

ssh -R 5555:localhost:5555 ubuntu@ec2serveraddress.com

My understanding is that the VNC server on Computer 2 should be piped down port 5555 to the EC2 server and if I tell Computer 1 to connect to localhost:5555 it should pipe to the same EC2 server on port 5555 which would then end at port 5900 on Computer 2.

I'm posting here though so clearly things aren't going well both computers connect to the EC2, but no VNC access is available. I'm new to SSH tunneling so I'm sure I'm missing something. Any ideas?

Any advice would be appreciated.

Edited by jasbur
Link to comment
Share on other sites

I do this exact same thing to remote into servers. I have always used local port forwarding for my vnc and remote desktop connections. So you may be able to do it with remote forwarding, but I have never tried it.

You have:

ssh -L 5900:localhost:5555 ubuntu@ec2serveraddress.com

I think the ports should be reversed and destination is not localhost but your server. So, it should look this:

ssh -L 5555:ec2serveraddress:5900 ubuntu@ec2serveraddress.com

Since we locally forward port 5555, we can access vnc using: in the vnc client

As an fyi, ubuntu@ec2serveraddress.com does not have to be on the same server, but needs to be able to access the server you are trying remote into

As an other side note, ubuntu server does not have a gui installed be default

Edited by arcane
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...