0

For some reason my autossh reverse tunnel does not work.

This is my command:

└─# autossh -M 12121 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /root/.ssh/id_rsa -R 12345:localhost:22 root@amazon

But for some reason, a listener opens on port 12121 over SSH and another one opens on 12122 for autossh. However, none opens at 12345 enter image description here

1 Answers1

0

autossh -M 12121 … opens ports 12121 and 12122 on the local side (where autossh works). -R 12345:localhost:22 is a request to open port 12345 on the remote side. I think 12121 is also used on the remote side, but the sole fact you observed 12122 used by autossh (which is a local process) tells me you were investigating things locally.

On the local computer you observed 12121 and 12122 being listened on. You did not observe 12345 being listened on because your local computer is not the remote server you had connected to.

If you ssh to the remote server and look there then you will probably find port 12345 open for listening (note: probably on the loopback interface only).

If you want a tunnel that listens locally then you need -L, not -R. I guess in this particular case you really want a tunnel that listens remotely, i.e. -R. The problem was you looked for its listening end on the wrong machine.