Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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 root@myvps.info

and so there is a sock listen on port 2221 in myvps.info

netstat -an 
tcp        0      0 127.0.0.1:2221          0.0.0.0:*               LISTEN  

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

ssh -p 2221 root@myvps.info 

but it returned:

ssh: connect to host myvps.info port 2221: Connection refused

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

PORT     STATE    SERVICE
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 stackoverflow.com Apr 16 '11 at 6:49

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

2  
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
add comment

2 Answers

You need to use:

ssh -fNR *:2221:localhost:22 root@myvps.info

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 root@myvps.info , but the netstat output is still "tcp 0 0 127.0.0.1:2221 *: LISTEN " –  mike Apr 16 '11 at 5:21
    
thanks , i have done it –  mike Apr 16 '11 at 5:33
add comment

Your netstat shows "127.0.0.1:2221", which means that it only listens on 127.0.0.1 (local connections). You'll need to configure another listening address, either a ip address of the machine, or 0.0.0.0 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
add comment

Your Answer

 
discard

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