Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to setup a reverse ssh tunnel as follows:

A ==========> B <----X---- C

I'm initiating the tunnel from A with:

ssh -p 443 -NR 19001:localhost:21 userOnB@B

On computer B I can use the tunnel fine if I use:

ssh -p 19001 userOnA@localhost

But if I'm connecting to B with its name, IP address or another computer (say C) I get a ssh: connect to host port 19001: Connection refused.

What is wrong?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

By default tunnel endpoints only listen on 127.0.0.1, so they can't be accessed from other machines. To change this you first need to add this to /etc/ssh/sshd_config on the server:

GatewayPorts clientspecified

and then when establishing the tunnel specify the listen address as 0.0.0.0:

ssh -p 443 -NR 0.0.0.0:19001:localhost:21 userOnB@B
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.