1

Starting autossh like so: autossh -M 5122 -N -R 5432:localhost:5432 <user>@<myhost>, I can't connect to localhost:5432. If I run ssh -f <user>@<myhost> -L 5432:localhost:5432 -N -v -v, I can.

The output from autossh:

debug1: Local connections to LOCALHOST:5122 forwarded to remote address 127.0.0.1:5122
debug1: Local forwarding listening on ::1 port 5122.
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 5122.
debug2: fd 7 setting O_NONBLOCK
debug1: channel 1: new [port listener]
debug1: Remote connections from LOCALHOST:5122 forwarded to local address 127.0.0.1:5123
debug1: Remote connections from LOCALHOST:5432 forwarded to local address localhost:5432
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: remote forward success for: listen 5122, connect 127.0.0.1:5123
debug1: remote forward success for: listen 5432, connect localhost:5432
debug1: All remote forwarding requests processed

And from ssh:

debug1: Local connections to LOCALHOST:5432 forwarded to remote address localhost:5432
debug1: Local forwarding listening on ::1 port 5432.
debug2: fd 6 setting O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 5432.
debug2: fd 7 setting O_NONBLOCK
debug1: channel 1: new [port listener]
debug1: Requesting [email protected]
debug1: forking to background
debug1: Entering interactive session.

I've just recently started playing around with ssh tunneling and cannot figure out why autossh will only forward port 5122.

1 Answer 1

1

A bit late to answer, but maybe it still helps someone.

I had the same problem, turns out you need to use -L instead of -R:

autossh -M 5122 -L 5432:localhost:5432 <user>@<myhost>
1
  • Further explanation here: -L and -R do different things: -L forwards traffic from a port on the local machine into a port on the remote machine while -R does the reverse: forwards traffic from the remote machine back to the local machine. So the autossh and ssh commands in the original question were not equivalent. Commented Oct 15, 2018 at 21:39

You must log in to answer this question.

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