Bug#860561: autossh restarts SSH session every $AUTOSSH_POLL seconds if (auto)ssh is called with option "-6" (i.e. when enforcing IPv6 usage)

2017-04-18 Thread Axel Beckert
Dear Carson,

today I stumbled upon the following issue with at least autossh 1.4e,
but likely all versions since 1.2c:

If ssh (OpenSSHversion 7.4p1 in my case) is called with option "-6",
all local port forwardings listen on IPv6 localhost (i.e. ::1) only,
too.

But autossh attempts to "pass traffic on the monitor forwarded port"
only on IPv4 localhost (127.0.0.1) which causes the error message

  connect_to 127.0.0.1: unknown host (Address family for hostname not supported)

and then kills and respawns the SSH connection.

An easy way to reproduce this on a IPv6-capable host is this simple
command:

  env AUTOSSH_POLL=2 autossh -6 localhost

This issue is probably caused by or at least related to this change in
1.2c:

  use Marcus Friedl's suggestion to simply connect to "127.0.0.1" 
  rather than "localhost", as not really using IPv6 anyway. And this
  gets rid of annoying ipv6 localhost message on Solaris at least.

But then again, just changing "127.0.0.1" to "localhost" doesn't seem
to fix the issue. Now I get this error message:

  connect_to localhost port 60059: failed.

And in the syslog this one:

  timeout polling to accept read connection 

I've tried this with hosts which have both, A and  record, host
which only have an  record and pure IPv6 addresses.

So I'm not sure what's the proper way to solve this. Maybe an option
or environment variable to configure "mhost" dynamically or by the
user if needed?

Looking at the presence of the option "-6" or "-o AddressFamily=inet6"
is probably only a workaround to mitigate the issue as the
AddressFamily option could also be configured in .ssh/config, even
only per host. And I don't think autossh should start parsing
.ssh/config.

Maybe there's a chance to gather on which IP address the child ssh
process is listening to in the /proc file system. But then again,
that's probably linux-specific and might not work on other Unices. :-/

P.S.: I've documented this in the Debian bug tracking system at
https://bugs.debian.org/860561 -- if you Cc 860...@bugs.debian.org,
your replies will show up and be archived under that URL, too.

Regards, Axel
-- 
 ,''`.  |  Axel Beckert , http://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5
  `-|  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE


signature.asc
Description: Digital signature


Bug#860561: autossh: Restarts SSH session every $AUTOSSH_POLL seconds if (auto)ssh is called with option "-6" (i.e. when enforcing IPv6 usage)

2017-04-18 Thread Axel Beckert
Package: autossh
Version: 1.4e-3
Severity: normal
Tags: upstream, ipv6

If ssh (OpenSSH, Debian package version 1:7.4p1-10 as currently in
Debian Stretch) is called with option "-6", all local port forwardings
only listen in IPv6 localhost (i.e. ::1) only, too.

But autossh attempts to pass traffic on the monitor forwarded port" only
on 127.0.0.1 which causes the error message

  connect_to 127.0.0.1: unknown host (Address family for hostname not supported)

and then kills and respawns the SSH connection.

An easy way to reproduce this on a IPv6-capable host is this simple
command:

  env AUTOSSH_POLL=2 autossh -6 localhost

-- System Information:
Debian Release: 9.0
  APT prefers unstable
  APT policy: (990, 'unstable'), (600, 'testing'), (500, 'unstable-debug'), 
(500, 'buildd-unstable'), (110, 'experimental'), (1, 'experimental-debug'), (1, 
'buildd-experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages autossh depends on:
ii  libc62.24-10
ii  openssh-client [ssh-client]  1:7.4p1-10

autossh recommends no packages.

autossh suggests no packages.

-- no debconf information