up vote 2 down vote favorite
share [g+] share [fb]

I want to connect to my computer(local) behind NAT through public accessible server(public).

On local:

ssh -g -R 8000:localhost:22 user@public

Then on public:

ssh -p 8000 user@public But I am getting error: Connection refused.

When I login to public server I can verify that tunnel is working by:

ssh -p 8000 localhost

Which opens ssh on local computer.

Am I suspecting wrong that public server should act as transparent proxy? Or how to make it working like that.

Thanks

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

SSH remote port forwards will default binding to localhost/loopback for security purposes. It's not often preferable to allow other hosts access to your forwarded ports.

To override this behaviour you will need to do two things:

  • Enable the GatewayPorts option on the server.
  • Specify a bind address, or * to bind to all addresses, on the client.

    ssh -R \*:8000:localhost:22 user@public
    

Escape the asterisk to ensure that your shell doesn't expand it.

link|improve this answer
feedback

This looks more like a problem with the settings on the remote computer public. By default the openssh sshd (which I guess is the one being used) the setting GatewayPorts turned to no, which forces remote port forwarding to only listen on localhost.

The solution would then be to edit your /etc/ssh/sshd_config (or equivalent), setting GatewayPorts to yes or to clientspecified. In case you choose the later you will have to change your tunnel request to something like -R *:8000:localhost:22 instead.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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