From owner-freebsd-questions@freebsd.org Thu Jun 14 15:27:29 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 B6A95100D9BF for ; Thu, 14 Jun 2018 15:27:29 +0000 (UTC) (envelope-from byrnejb@harte-lyne.ca) Received: from inet08.hamilton.harte-lyne.ca (inet08.hamilton.harte-lyne.ca [216.185.71.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "inet08.hamilton.harte-lyne.ca", Issuer "CA_HLL_ISSUER_2016" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 53B1270201 for ; Thu, 14 Jun 2018 15:27:29 +0000 (UTC) (envelope-from byrnejb@harte-lyne.ca) Received: from localhost (localhost [127.0.0.1]) by inet08.hamilton.harte-lyne.ca (Postfix) with ESMTP id 438DE62568 for ; Thu, 14 Jun 2018 11:27:22 -0400 (EDT) X-Virus-Scanned: amavisd-new at harte-lyne.ca Received: from inet08.hamilton.harte-lyne.ca ([127.0.0.1]) by localhost (inet08.hamilton.harte-lyne.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rCFUrogRGTjT for ; Thu, 14 Jun 2018 11:27:19 -0400 (EDT) Received: from webmail.harte-lyne.ca (inet04.hamilton.harte-lyne.ca [216.185.71.24]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by inet08.hamilton.harte-lyne.ca (Postfix) with ESMTPSA id 3534A6255A for ; Thu, 14 Jun 2018 11:27:19 -0400 (EDT) Received: from 216.185.71.44 (SquirrelMail authenticated user byrnejb_hll) by webmail.harte-lyne.ca with HTTP; Thu, 14 Jun 2018 11:27:19 -0400 Message-ID: <5387e3bd234fcae7274d3202fd89d71d.squirrel@webmail.harte-lyne.ca> Date: Thu, 14 Jun 2018 11:27:19 -0400 Subject: FreeBSD-11.1p10 and autossh From: "James B. Byrne" To: freebsd-questions@freebsd.org Reply-To: byrnejb@harte-lyne.ca User-Agent: SquirrelMail/1.4.22-5.el6 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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 15:27:30 -0000 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 not otherwise?? -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail Do NOT open attachments nor follow links sent by e-Mail James B. Byrne mailto:ByrneJB@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3