1

I have kind of a naive question, but by reading this thread for example: https://superuser.com/questions/37738/how-to-reliably-keep-an-ssh-tunnel-open

One can see in the accepted answer how to use autossh, e.g.:

autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C

But from the man page of autossh https://manpages.ubuntu.com/manpages/focal/man1/autossh.1.html I can only see 3 available options: -M, -f and -V.

Same thing on my system:

$ autossh --help
/usr/lib/autossh/autossh: invalid option -- '-'
usage: autossh [-V] [-M monitor_port[:echo_port]] [-f] [SSH_OPTIONS]

    -M specifies monitor port. Overrides the environment
       variable AUTOSSH_PORT. 0 turns monitoring loop off.
       Alternatively, a port for an echo service on the remote
       machine may be specified. (Normally port 7.)
    -f run in background (autossh handles this, and does not
       pass it to ssh.)
    -V print autossh version and exit.

Environment variables are:
    AUTOSSH_GATETIME    - how long must an ssh session be established
                          before we decide it really was established
                          (in seconds). Default is 30 seconds; use of -f
                          flag sets this to 0.
    AUTOSSH_LOGFILE     - file to log to (default is to use the syslog
                          facility)
    AUTOSSH_LOGLEVEL    - level of log verbosity
    AUTOSSH_MAXLIFETIME - set the maximum time to live (seconds)
    AUTOSSH_MAXSTART    - max times to restart (default is no limit)
    AUTOSSH_MESSAGE     - message to append to echo string (max 64 bytes)
    AUTOSSH_PATH        - path to ssh if not default
    AUTOSSH_PIDFILE     - write pid to this file
    AUTOSSH_POLL        - how often to check the connection (seconds)
    AUTOSSH_FIRST_POLL  - time before first connection check (seconds)
    AUTOSSH_PORT        - port to use for monitor connection
    AUTOSSH_DEBUG       - turn logging to maximum verbosity and log to
                          stderr

Where do the -N, -R and -C options come from? Am I not looking at the right place?

1 Answer 1

4
usage: autossh [-V] [-M monitor_port[:echo_port]] [-f] [SSH_OPTIONS]

Those are the [SSH_OPTIONS], options that are passed as-is by autossh to ssh and handled by ssh there.

See man ssh for those.

2
  • Oh gosh, Ok, I totally misunderstood those! I thought they were referencing the environment variables at the bottom of the help. But then... how is handled the case of the -f option which is present in both commands?! And is it also possible with autossh to make use an SSH service, manually defined in the ~/.ssh/config file?
    – s.k
    Commented Jan 29, 2022 at 19:05
  • 1
    @s.k: from the usage message you posted in your question: -f run in background (autossh handles this, and does not pass it to ssh.). Read the part in parentheses. I have no idea what an 'SSH service ... in .ssh/config' is -- do you mean some option(s), or a host (or pseudo-host) block? If so, yes autossh runs ssh and ssh uses config in the same way as any other run of ssh. Commented Jan 30, 2022 at 0:47

You must log in to answer this question.

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