0

I have a local machine M that I want to expose to the internet, and I can't use port forwarding. I want to open port 22 on M to the internet, using my vps S as a proxy. I want to use this port to have ssh access, so the solution must allow all tcp traffic, not just http, as many other questions have asked here. I have tried using ssh -f -N -R 9000:localhost:22 example.com on M, where localhost is M and example.com is a domain name pointing to S. This allows machine S to access M over S:9000, but not arbitrary machines on the internet to access M through example.com:9000, which is what I want. (note that the port that arbitrary machines connect to does not necessarily need to be the same port that S can connect to M through.) I tried using an nginx tcp reverse proxy, but it doesn't seem to work.

Some notes:

The forwarding itself does not need to be done using ssh, I know it is somewhat slow.

I intend to leave this running for long periods of time (I know this might be a security risk).

If it matters at all, M runs Arch Linux, and S runs Debian 10 Buster.

1 Answer 1

1

The probable issue is the configuration of sshd on S.

In /etc/ssh/sshd_config you need to ensure you have

GatewayPorts yes

to allow connections from arbitrary hosts. After changing this value you need to restart ssh

sudo systemctl restart ssh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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