From owner-freebsd-questions@freebsd.org Thu Jun 14 18:08:13 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB2D910191D5 for ; Thu, 14 Jun 2018 18:08:13 +0000 (UTC) (envelope-from dch@skunkwerks.at) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77B907868A for ; Thu, 14 Jun 2018 18:08:13 +0000 (UTC) (envelope-from dch@skunkwerks.at) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E2AFC21928 for ; Thu, 14 Jun 2018 14:08:12 -0400 (EDT) Received: from web6 ([10.202.2.216]) by compute7.internal (MEProxy); Thu, 14 Jun 2018 14:08:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skunkwerks.at; h=content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=fjRzW3eTtmzLSRDdBrNqUAFJdRosH eSojIrOhMwlSCo=; b=h/m7LRi+LrIbo0ZeHAvtUTCe1YyRek54lJ+Igtjso3jQC PsXa+YpgTNl6jTgIdo6YoFm5ZxfcH2a/Z533KELFVhP3Oi4YvYF9v8WvPi2ljksF JASByKbloz8lcEARtYm/LcS7Z4Y4cZ1ekqY71DkudDmwgxJORkZEJVig7vQAjfYF dZ9vc6/rAge8ww2Y1bC1WOJlyacU5IF+VDVx15Aayl6EI/sxr0AVYpHSg4cTTNol TFD6dqF9/F9e1WzWwNUH4EGJ09CZx+/Aw2NvEGlhAKYYlL25Nv4YCrGtF6NiaHWf BqA+Xrd0HKqzTSXX0hb7fbqA71RhCjf6M+oIFw/Ew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=fjRzW3 eTtmzLSRDdBrNqUAFJdRosHeSojIrOhMwlSCo=; b=Z7Okg/OOSd9plx3qVNilze MaV4xtTIwGZQzT+F++W61/A4iHSqYfU1htLhbPcESJ9/OFEWYjlTC2uCbAfRcNL+ z9szBOGxZo69SyJLjBpGpsk30Oshda5+kMUd1OfPa+1TJ/p53ZDQOX6MM2QCuCYG E91TqYzGCxZNNhDuJx3g56D0ygD+3SFRj+dz0IZMSfi5bn3jEs2tuZoECHpx26qd e1Tp4LHBSlANl1DmlgvQhcowwWtXXfc5n7YpMO3y3ikwsAoz7R8309NniqukE8uo mTMTwlMDAPELOIJTS9lwFRunUY4LA6tNc0DGXczyTRlj7uAa0oCyyWY7G4S+2C+A == X-ME-Proxy: X-ME-Sender: Received: by mailuser.nyi.internal (Postfix, from userid 99) id 5EB4A418C; Thu, 14 Jun 2018 14:08:12 -0400 (EDT) Message-Id: <1528999692.3556650.1408287616.420E9370@webmail.messagingengine.com> From: Dave Cottlehuber To: freebsd-questions@freebsd.org MIME-Version: 1.0 X-Mailer: MessagingEngine.com Webmail Interface - ajax-498d70f2 Subject: Re: FreeBSD-11.1p10 and autossh References: <5387e3bd234fcae7274d3202fd89d71d.squirrel@webmail.harte-lyne.ca> In-Reply-To: <5387e3bd234fcae7274d3202fd89d71d.squirrel@webmail.harte-lyne.ca> Date: Thu, 14 Jun 2018 20:08:12 +0200 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.26 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 18:08:14 -0000 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