Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a burst VPS server and my home computer is behind a NAT. I want to use ssh redirection to connect with my home computer at another place.

I do this in my home computer:

ssh -fNgR 2221:localhost:22

and so there is a sock listen on port 2221 in

netstat -an 
tcp        0      0*               LISTEN  

now i want to connect with my home computer with command bellow

ssh -p 2221 

but it returned:

ssh: connect to host port 2221: Connection refused

I use nmap to see what port is open on there vps server it shows:

22/tcp   open     ssh
80/tcp   open     http
135/tcp  filtered msrpc
139/tcp  filtered netbios-ssn
445/tcp  filtered microsoft-ds
593/tcp  filtered http-rpc-epmap
4444/tcp filtered krb524

on 2221 port open! why and how can i slove this problem?

share|improve this question

migrated from Apr 16 '11 at 6:49

This question came from our site for professional and enthusiast programmers.

Will you be solving it with programming? – Ignacio Vazquez-Abrams Apr 16 '11 at 4:41
thanks second floor , i don't know there is acceptable answer you can set before. – mike Apr 16 '11 at 4:54

2 Answers 2

Your netstat shows "", which means that it only listens on (local connections). You'll need to configure another listening address, either a ip address of the machine, or which usually means all addresses available.

share|improve this answer
how could i configure it ? could you tell me more ? – mike Apr 16 '11 at 4:47

You need to use:

ssh -fNR *:2221:localhost:22

which will bind the server's listening socket to all network interfaces (not just localhost), and

GatewayPorts yes

in your /etc/sshd_config file (the exact path may vary depending on your Linux distribution).

See the ssh and ssh_config man pages for more information.

share|improve this answer
i use the command , ssh -fNR :2221:localhost:22 , but the netstat output is still "tcp 0 0 *: LISTEN " – mike Apr 16 '11 at 5:21
thanks , i have done it – mike Apr 16 '11 at 5:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.