2

When running autossh without the "-f" option, everything works fine. Adding the "-f" option indeed sends autossh to the background, but after the ssh tunneling established correctly the autossh itself exit, leaving the ssh connection without monitor.

Here is the command I'm running: autossh -f -M 20000 -N -L 0.0.0.0:5601:10.10.0.8:5601 10.10.0.8

Anyone knows what can cause this problem? alternatively - anyone knows how can I debug autossh when using the "-f"? (is there any log file produce when using AUTOSSH_DEBUG=1)?

(I'm running on Ubuntu 14.04)

Thanks, Shay

Shay Tsadok
  • 913
  • 1
  • 7
  • 26

2 Answers2

2

Seeing as no one has a better suggestion... Try running autossh under a watchdog like daemontools. With this method autossh runs as a foreground child of a supervise daemon (so, no -f switch). You can start and stop it with the svc command, and you can log all of its output with multilog.

This method has proven sufficiently reliable for me, on a fleet of production boxes.

dan4thewin
  • 1,134
  • 7
  • 10
  • Thanks for the tip. daemontools look like a solid workaround for that problem. For now I used "screen" which also allows me to run it without the "-f", but I think that for production use cases daemontools is the right tool. – Shay Tsadok Feb 21 '16 at 16:57
2

On macOS I had a problem where autossh -M 0 -R 1234:localhost:22 worked but adding -f to make autossh run in background would log the following and autossh would die instantly:

2018/04/10 12:00:06 autossh[67839]: ssh exited with status 0; autossh exiting

Adding -N ("Do not execute a remote command.") fixed the issue:

autossh -f -M 0 -N -R 1234:localhost:22

Seeing you already had -N in the command this is probably unrelated but possibly helpful to others.

raine
  • 1,694
  • 17
  • 14