autossh fails with exit status 1 and no error message

1.9k views Asked by At

I'm trying to run autossh (on a VM running CentOS6), but it's exiting immediately with the help message. I think this is a system issue because when I run it with the exact same parameters on another computer (running Ubuntu 14.04) it works fine. It's also fine when I run the same command but with ssh instead of autossh. So I tried strace to see if anything's wrong there. But if there is I'm not sure what it is. Any ideas?

Here's the autossh command: autossh -oStrictHostKeyChecking=no -oServerAliveInterval=15 -oServerAliveCountMax=4 -L 3130:localhost:3130 -N -i /path/to/some.pem user@remotehost

Here's the strace output (note myserver is an entry in .ssh/config that contains the same parameters as the previous command):

execve("/usr/local/bin/autossh", ["autossh", "myserver"], [/* 55 vars */]) = 0
brk(0)                                  = 0xefc000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f26193cc000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=36751, ...}) = 0
mmap(NULL, 36751, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f26193c3000
close(3)                                = 0
open("/lib64/libnsl.so.1", O_RDONLY)    = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p@\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=113432, ...}) = 0
mmap(NULL, 2198192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2618f95000
mprotect(0x7f2618fab000, 2093056, PROT_NONE) = 0
mmap(0x7f26191aa000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7f26191aa000
mmap(0x7f26191ac000, 6832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f26191ac000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\356\1\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1920936, ...}) = 0
mmap(NULL, 3750152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2618c01000
mprotect(0x7f2618d8b000, 2097152, PROT_NONE) = 0
mmap(0x7f2618f8b000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x7f2618f8b000
mmap(0x7f2618f90000, 18696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2618f90000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f26193c2000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f26193c1000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f26193c0000
arch_prctl(ARCH_SET_FS, 0x7f26193c1700) = 0
mprotect(0x7f2618f8b000, 16384, PROT_READ) = 0
mprotect(0x7f26191aa000, 4096, PROT_READ) = 0
mprotect(0x7f26193cd000, 4096, PROT_READ) = 0
munmap(0x7f26193c3000, 36751)           = 0
write(2, "usage: autossh [-V] [-M monitor_"..., 69usage: autossh [-V] [-M monitor_port[:echo_port]] [-f] [SSH_OPTIONS]
) = 69
write(2, "\n", 1
)                       = 1
write(2, "    -M specifies monitor port. M"..., 238    -M specifies monitor port. May be overridden by 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.)
) = 238
write(2, "    -f run in background (autoss"..., 85    -f run in background (autossh handles this, and does not
       pass it to ssh.)
) = 85
write(2, "    -V print autossh version and"..., 39    -V print autossh version and exit.
) = 39
write(2, "\n", 1
)                       = 1
write(2, "Environment variables are:\n", 27Environment variables are:
) = 27
write(2, "    AUTOSSH_GATETIME    - how lo"..., 259    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.
) = 259
write(2, "    AUTOSSH_LOGFILE     - file t"..., 107    AUTOSSH_LOGFILE     - file to log to (default is to use the syslog
                          facility)
) = 107
write(2, "    AUTOSSH_LOGLEVEL    - level "..., 49    AUTOSSH_LOGLEVEL    - level of log verbosity
) = 49
write(2, "    AUTOSSH_MAXLIFETIME - set th"..., 65    AUTOSSH_MAXLIFETIME - set the maximum time to live (seconds)
) = 65
write(2, "    AUTOSSH_MAXSTART    - max ti"..., 69    AUTOSSH_MAXSTART    - max times to restart (default is no limit)
) = 69
write(2, "    AUTOSSH_MESSAGE     - messag"..., 74    AUTOSSH_MESSAGE     - message to append to echo string (max 64 bytes)
) = 74
write(2, "    AUTOSSH_PATH        - path t"..., 53    AUTOSSH_PATH        - path to ssh if not default
) = 53
write(2, "    AUTOSSH_PIDFILE     - write "..., 49    AUTOSSH_PIDFILE     - write pid to this file
) = 49
write(2, "    AUTOSSH_POLL        - how of"..., 70    AUTOSSH_POLL        - how often to check the connection (seconds)
) = 70
write(2, "    AUTOSSH_FIRST_POLL  - time b"..., 71    AUTOSSH_FIRST_POLL  - time before first connection check (seconds)
) = 71
write(2, "    AUTOSSH_PORT        - port t"..., 61    AUTOSSH_PORT        - port to use for monitor connection
) = 61
write(2, "    AUTOSSH_DEBUG       - turn l"..., 104    AUTOSSH_DEBUG       - turn logging to maximum verbosity and log to
                          stderr
) = 104
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?
+++ exited with 1 +++
2

There are 2 answers

4
Jakuje On

Come on ... the autossh exits with

write(2, "usage: autossh [-V] [-M monitor_"..., 69usage: autossh [-V] [-M monitor_port[:echo_port]] [-f] [SSH_OPTIONS]

which means that you specified wrong arguments and it is trying to explain you how the syntax looks like. To see what is wrong, there are several things you can try:

  • Use -vvv switches to ssh to see more verbose log from the ssh.
  • Use AUTOSSH_DEBUG environment variable to get some debug logs from autossh.
1
Benedikt Köppel On

I had exactly the same problem with autossh 1.4e on CentOS Linux 7. autossh stopped immediately and printed the help, without even trying to connect to SSH.

The solution was to specify -M 0 on the command line:

autossh -M 0 \
    -oStrictHostKeyChecking=no \
    -oServerAliveInterval=15 \
    -oServerAliveCountMax=4 \
    -L 3130:localhost:3130 \
    -N -i /path/to/some.pem user@remotehost