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

  • As per [autossh's manual](https://manpages.debian.org/autossh/autossh.1.en.html#Connection_setup): does it work when using only ssh without involving autossh? "It cannot be stressed enough that you must make sure ssh works on its own, that you can set up the session you want before you try to run it under autossh" – A.B Aug 23 '22 at 14:47
  • [Please don't post images of text](https://unix.meta.stackexchange.com/q/4086/108618). Not only you should post text as text; you should clearly state the exact command that gave you this output and where it was invoked (locally or `@amazon`). – Kamil Maciorowski Aug 23 '22 at 16:44

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.

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202