Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted

By default tunnel endpoints only listen on, 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

ssh -p 443 -NR userOnB@B
share|improve this answer
on ubuntu you might need sudo reload sshd – MaximKostrikin Jan 28 at 6:07

Your Answer


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.