3

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.

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

Thanks

2 Answers2

3

According to the manual, you may, on the public host, set the option (in sshd_config):

GatewayPorts yes

and then on local try

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

(note the extra *:).

If you do not have access to public's sshd_config, you may make an extra port forward like so:
on local (lancomp): ssh -R 8001:localhost:22 user@public
on public: ssh -g -L 8000:localhost:8001 user@lancomp

And to connect from outside, of course, in both cases: ssh -p 8000 user@public

Amir
  • 837
  • 8
  • 17
1

The listing on port 8000 will be made on the localhost address of the public macine only. If you want it to bind to the "real" network interface, you might try -R public:8000:localhost:22.