Date: Thu, 14 Jun 2018 20:08:12 +0200 From: Dave Cottlehuber <dch@skunkwerks.at> To: freebsd-questions@freebsd.org Subject: Re: FreeBSD-11.1p10 and autossh Message-ID: <1528999692.3556650.1408287616.420E9370@webmail.messagingengine.com> In-Reply-To: <5387e3bd234fcae7274d3202fd89d71d.squirrel@webmail.harte-lyne.ca> References: <5387e3bd234fcae7274d3202fd89d71d.squirrel@webmail.harte-lyne.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 14 Jun 2018, at 17:27, James B. Byrne via freebsd-questions wrote:> I cannot seem to configure autossh to work from anything other than > the command line, which defeats the purpose. I would like it to > automatically start when the system boots but I have been unsuccessful> in all my attempts to date. I have tried adding this in rc.conf: > > autossh -M0 -f -i /root/.ssh/id_ed25519 -L 143:localhost:143 > root@192.168.216.17 > > But there is no evidence that this even gets executed. In any case it> is not running after a restart and no error messages are logged. > > I created a primitive rd.d script which runs but which does not > establish a link between the systems. ps reports that autossh is > running and that it is the parent of a process pid. But that pid does> not exist and there is nothing logged anywhere that I can find to show> that it ever did. > > The options that I pass from rc.conf to the rc.d/autossh script are: > > autossh_enable="YES" # enable autossh > autossh_flags='-M0 -f \ > -i "/root/.ssh/id_rsa" \ > -o "ServerAliveInterval 30" \ > -o "ServerAliveCountMax 3" \ > -L "143:localhost:143" \ > -N \ > "root@192.168.216.17"' > > This starts autossh as shown below: > > ps -auxw | grep ssh > root 2971 0.0 0.0 8332 1640 - SsJ 10:52 0:00.00 > autossh: parent of 33977 (8) (autossh) > root 13736 0.0 0.1 57812 4856 - SsJ 10:52 0:00.00 > /usr/sbin/sshd > root 32028 0.0 0.1 85228 5620 - SsJ 10:52 0:00.02 sshd:> root@pts/1 (sshd) > root 34983 0.0 0.0 14828 1804 1 S+J 10:52 0:00.00 grep > --color ssh > > > But there is no connection to the remote host. If I run autossh from> the command line with the same options then I see this: > > autossh -M0 -f -i "/root/.ssh/id_rsa" -o "ServerAliveInterval 30"> -o "ServerAliveCountMax 3" -L "143:localhost:143" -N > "root@216.185.71.17"& > > > ps -auxw | grep ssh > . . . > root 53110 0.0 0.0 8332 1700 - IsJ 10:56 0:00.00 > autossh: parent of 53777 (1) (autossh) > root 53777 0.0 0.1 24580 4380 - SJ 10:56 0:00.03 > /usr/bin/ssh -i /root/.ssh/id_rsa -o ServerAliveInterval 30 -o Serv > . . . > > > The rc.d script is very basic and contains this: > > > source /etc/rc.subr > > name="autossh" > rcvar=autossh_enable > > load_rc_config $name > > : ${autossh_enable:="NO"} > : ${autossh_pidfile:="/var/run/autossh.pid"} > : ${autossh_procname:="/usr/local/bin/autossh"} > > start_cmd=${name}_start > stop_cmd=${name}_stop > > pidfile=${autossh_pidfile} > procname=${autossh_procname} > > autossh_start() { > AUTOSSH_PIDFILE=${autossh_pidfile} ${autossh_procname} > ${autossh_flags}> AUTOSSH_DEBUG=7 > AUTOSSH_LOGLEVEL=7 > AUTOSSH_LOGFILE="/var/log/autossh.log" > } > autossh_stop() { > kill -9 "$(cat ${AUTOSSH_PIDFILE})"; > rm -f "${AUTOSSH_PIDFILE}" > } > run_rc_command "$1" > > But this does not work as I expect either. fROM THE CLI 'service > autossh start' runs autossh but autossh does not establish an ssh > connection to the target. The pid autossh claims to be the parent of > does not exist when I search for it using ps. Despite the debugging > and logging settings nothing appears in the autossh logfile. There is> nothing in /var/log/auth.log on the target host to indicate that an > ssh connection is even attempted. > > This is more of an annoyance than anything else but I am mystified > that something as basic as this just will not run as I expect. Why > does autossh work as expected when started from the command line but I highly recommend spiped https://www.freshports.org/sysutils/spiped/ and leave autossh in the dust where it belongs. It has an rc.d script and is robust against failure. A+ Dave
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1528999692.3556650.1408287616.420E9370>