# ssh port forwarding - Forwarded connection refused by server

## sbyrne

I am trying to forward a port through ssh, specifically port 5999 for vnc.  I am using putty from a windows machine to make the ssh connection, which works fine.  The putty event log says "Local port 5999 forwarding to <myhost>:5999".  Then I run a vncviewer for "localhost:99".  It doesn't work.  The putty event log says "Forwarded connecton refused by server".  This happens with both vnc and tightvnc.  I tried "iptables --flush" first.  I've tried it from multiple windows machines.  So I am assuming it is an openssh problem.  The only uncommented things i have in my sshd_config are:

PermitRootLogin No

UsePrivilegeSeperation Yes

Subsystem sftp /usr/lib/msic/sftp-server

Any ideas?

----------

## Maz

Well, I read it like 20 times, and I still don't understand what you are trying to do   :Confused:  . Or more precisely, how exactly you want to connect with your vnc server.

Could you try to explain it a little better ?

----------

## thehyperintelligentslug

Hi,

This is the method I use for forwarding my VNC ports from my flat to my work machine (using puTTY);

At the flat I have a vncserver started.

At work I connect with ssh and forward like this:

```

source port     destination

L5801             localhost:5801

L5901             localhost:5901

```

Now, when I point my browser at localhost:5801 I can access my vnc server.

I think that is what your after.

Cheers,

Neil.

----------

## sbyrne

 *thehyperintelligentslug wrote:*   

> Hi,
> 
> This is the method I use for forwarding my VNC ports from my flat to my work machine (using puTTY);
> 
> At the flat I have a vncserver started.
> ...

 

Ah!  I was trying to do:

```

L5999             <server host>:5999

```

instead of

```

L5999              localhost:5999

```

.

If you are running vnc on 5901, what is the 5801 for?

----------

## philthedrill

Could you give a detailed diagram of the machines in your path (client, ssh server, vnc server, etc), including OS info and version numbers of vnc and putty?

I'll give you an example of what I'm doing, because I struggled with port forwarding for a bit.

I want to connect to my home PC from school. At home I have a FreeBSD box running openssh (we'll call it 'zb') and a Windows XP box running vnc server on default port 5900 (we'll call it 'uc'). There's a firewall at home, and the only open port is ssh to zb, so uc is closed to the outside. Traffic between zb and uc (behind the firewall) is unrestricted.

In Putty, I set up the ssh connection as normal. Then under SSH -> Tunnels, I added a new forwarded port.

Source port: 5902 (in your case, 5999)

Destination: uc:5900

The "Local" radio box should be checked, and then I click "Add".

With vncviewer, I type localhost:2, and it should connect.

The concept of port forwarding that tripped me up is the destination. uc:5900 is from the perspective of the ssh daemon, not the ssh client.

If all else fails, start using telnet to log into specific ports and see if they're open. Also, run 'netstat -a' on the machines to view active connections.

HTH.

--phil

----------

## philthedrill

Oops. Looks like I was a little late on my post.

Port 5800 is for vncserver through a web server, which can be viewed through a java capable browser.

I've never used it.

--phil

----------

## thehyperintelligentslug

Hi,

 *Quote:*   

> 
> 
> If you are running vnc on 5901, what is the 5801 for?
> 
> 

 

To tell you the truth, I can't quite remember!  :Rolling Eyes: 

Best guess is that it was when I was trying to get it to work and it just got left there! (didn't mean to post it on here but forgot to edit it out!).  :Embarassed: 

Ahh, well!  :Laughing: 

As for the problem you were having, I remember doing the same thing.

Cheers,

Neil.

----------

## thehyperintelligentslug

Bingo  :Exclamation: 

 *Quote:*   

> Port 5800 is for vncserver through a web server, which can be viewed through a java capable browser.
> 
> 

 

Thanks phil, I was googling away to try and figure out why that was there! I use the web access as we are restricted on what software we can have on our PC's here.

Cheers,

Neil.

----------

