0

I want to connect to Server A which is behind a NAT and a firewall which blocks all incoming connections. I want to access port 9000. In my office I have a public IP and control of the router. My idea is to run autossh on Server A which establishes a tunnel to Server B in my office. Then use another autossh tunnel to go back and forward port 9000 to 9001. I feel like I'm halfway there.

On the remote server, I have a systemd service running:
autossh -M 0 -q -N -p 22 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -R :2222:localhost:22 [email protected]

Now I can connect to Server B from my laptop with
ssh [email protected] -p 2222

I'm trying to forward the port like this:
ssh [email protected] -p 2222 -L :9001:localhost:9000 -N

So now I expect I can connect from my laptop to 192.168.1.10:9001 but I get connection refused.

1 Answer 1

1

You should connect to port 9001 on your laptop (likely localhost) and this will forward the connection to port 9000 on your ssh endpoint.

BTW, you can also modify your autossh the following way:

autossh -M 0 -q -N -p 22 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -R :2222:localhost:22 -R :9001:localhost:9000 [email protected]

and connect to port 9001 on 192.168.1.10 and this will forward to port 9000 on ssh client.

I assume you realize this may be an offense resulting in termination.

2
  • Doh! Of course, that was it. I did not realize you can have more than on -R flag, that actually seems like a better way. What do you mean about an offense, is there some security issue with this?
    – Elliott B
    Jun 6, 2019 at 20:20
  • 1
    There certainly is a reason why the firewall blocks incoming connections (whether it makes sense or not is irrelevant). Punching a hole like this in FW may be considered a security breach and such things usually end up in employment termination.
    – Tomek
    Jun 6, 2019 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .