Re: Trouble using VNC thru a ssh tunnel

From: Anders Larsen (
Date: 04/26/02

From: Anders Larsen <>
Date: Fri, 26 Apr 2002 11:34:28 +0200

Gary wrote:

> I am able to run VNC without port forwarding by starting a vncserver
> on work and issuing the command 'vncviewer work:1' from home.
> But when I do this with port forwarding (work:5901 --> home:5902) by
> first establishing a ssh connection with 'ssh -L 5902:work:5901 work'
> and then issuing the command 'vncviewer localhost:2' from another
> pseudotty, I get the following error.
> vncviewer: VNC server closed connection

The hostname in the -L option is as seen by the *remote* side;
use 'ssh -L 5902:localhost:5901 work' instead.
This will cause 'work' to connect to 'localhost:5901', that is,
to itself (which is what you want, I guess).

(BTW, if the vncserver isn't listening to 5901 you get the same
error message).

> debug1: Connections to local port 5902 forwarded to remote address
> work:5901
> socket: Address family not supported by protocol
> I have tried forcing
> ssh protocol 1 and ssh protocol 2, but this had no effect.

I get the same debug output here - it seems it can be safely ignored.
As long as ssh doesn't complain without the -v option, all is well.

> I use iptables on both home and work, so I disabled the iptables rules
> on both machines for a short period of time, but this had no effect.