Link to home
Start Free TrialLog in
Avatar of Brandon Lyon
Brandon Lyon

asked on

SSH VNC tunnel setup problems

I'm trying to follow this guide in order to setup an SSH tunnel for VNC onto an ubuntu desktop from a Windows desktop.

I can connect via SSH but the moment I start the VNC connection to localhost::5902 I immediately get the following message:

"Connection has been gracefully closed".

Any ideas what could be causing this? Is it a bad setting on the Ubuntu computer I'm trying to VNC into? Did I configure PuTTY or TightVNC wrong? Is it because I changed the default SSH port number? Is there something I need to do on my router other than port forward the ssh connection appropriately (which I already did)? Is there an alternate method you would suggest?

Ubuntu 16.04 LTS & Windows 10, both 64 bit.
Avatar of gelonida
gelonida
Flag of France image

can you show us the exact ssh command that you typed and tell us how you started vnc on your target ubuntu machine. (to see on which port it is listening locally)

I suspect as you hint already a port number mismatch somewhere in your setup.
Avatar of Brandon Lyon
Brandon Lyon

ASKER

The remote port used instead of 22 is 5999.
The rest was done following the steps in the guide I linked.
The local ssh session was started with
ssh -p 5999 [redacted server ip]
The command run locally once I was SSH in was
"x11vnc -safer -localhost -nopw -once -display :0"
Then I started PuTTy and followed the instructions in the guide I linked.
SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your description sounds correct, but I am not sure how I would enter a raw ssh command from a Windows machine, such as
ssh -p 5999 -L 5902:localhost:5900 [redacted server ip]

Open in new window

The guide I linked describes using PuTTY for that purpose but as far as I can tell I cannot enter raw terminal commands until a connection is made.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks I didn't think to try launching from a command prompt.

I tried that command and got an "Error in TightVNC Viewer: No security types supported. Server sent security types, but we do not support any of them."
For portforwarding without command line you might try in the putty GUI (I don't have windows so I can't try)

Putty -> Configuration -> SSH -> Tunnels:

Destination: local
source port 5902
destination: localhost:5900
I tried the configuration you just recommended and it says "specified forwarding already exists"
I tried a different VNC client (VNC Viewer) and upon connecting to localhost::5902 I got an error message of "the connection closed unexpectedly"
sorry our messages crossed.

probably you had still the other port forwarding from command line open.

I think the port forwarding is now working.

The issue that you have now is, that your x11vnc does not provide any authentication method, that is known by tour tightvnc client.

I don't have a windows PC to try, but you can try following:


start an x11vnc saession with a password:

using the commands:


x11vnc -storepasswd

x11vnc -safer -localhost -usepw -once -display :0
Thanks. I just tried the usepw switch you recommended after storepasswd. I get the original error message of "connection gracefully closed" or "connection closed unexpectedly" depending on which viewer I use.
I guess, that when trying to do port forwarding once from command line and once from the GUI lost the forwarding.

I suggest to
: close all putty windows (or if you want to be even safer. restart your local PC)

- then use the putty command with port forwarding
- start the x11vnc command ( "x11vnc -safer -localhost -nopw -once -display :0" )
   you should get the error about "No security types supported. "

then you try the same with the other x11vnc command ( x11vnc -safer -localhost -usepw -once -display :0  )

please note:

you cannot have putty windows with identical port forwarding, the second putty will fail and not forward.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perfect.


Enjoy and have fun.