4

I use ssh -D 12345 [email protected] to set up dynamic port forwarding via host somewhere.com. I want to switch to using autossh to daemonize the thing and to make sure I don't need to manually monitor it.

I installed the autossh package (on my Linux Mint 18.1), but I don't quite understand what I'm supposed to do. Why aren't there any configuration/defaults files under /etc/? Where's the service which starts autossh tunnles? Do I need to do all of that manually?

einpoklum
  • 8,772
  • 19
  • 65
  • 129

2 Answers2

4

Explanation for fingerpich's answer:

  • autossh -f causes autossh to drop to the background before running ssh.

  • -M specifies a monitoring port for autossh to use.

  • -D specifies the local socks proxy port

  • -N specifies do not execute a remote command. this is useful for just forwarding ports

If you don't want to use a monitoring port the following command instead uses SSH keep-alives every 10 seconds to detect failure:

autossh -f -M 0 -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -D localhost:1234 -N [email protected]
muru
  • 69,900
  • 13
  • 192
  • 292
2

I found the answer here and used the following command

autossh -f -M 5731 -D localhost:1234 -N user@ip
fingerpich
  • 121
  • 4