From owner-freebsd-questions@FreeBSD.ORG Tue Oct 21 23:21:56 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6F5A10656C0 for ; Tue, 21 Oct 2008 23:21:56 +0000 (UTC) (envelope-from jalmberg@identry.com) Received: from mx1.identry.com (on.identry.com [66.111.0.194]) by mx1.freebsd.org (Postfix) with ESMTP id 5B73A8FC1C for ; Tue, 21 Oct 2008 23:21:55 +0000 (UTC) (envelope-from jalmberg@identry.com) Received: (qmail 91504 invoked by uid 89); 21 Oct 2008 23:21:55 -0000 Received: from unknown (HELO ?192.168.1.110?) (jalmberg@75.127.142.66) by mx1.identry.com with ESMTPA; 21 Oct 2008 23:21:55 -0000 Mime-Version: 1.0 (Apple Message framework v753.1) In-Reply-To: <51D1673D-4689-4F9A-8217-CFC5C58A1145@identry.com> References: <8B945891-5F96-4FBF-8175-15F67F03DD92@identry.com> <48D8F881.1010000@unsane.co.uk> <912A74FB-0292-4A53-B480-34FE69D9C465@identry.com> <20081020212103.GA13334@icarus.home.lan> <007ABF71-6D85-4849-A9E7-933D18236EE8@identry.com> <48FD8876.5090805@infracaninophile.co.uk> <51D1673D-4689-4F9A-8217-CFC5C58A1145@identry.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <33DD5BC0-7D57-4530-BB59-46E2D7A43F1A@identry.com> Content-Transfer-Encoding: 7bit From: John Almberg Date: Tue, 21 Oct 2008 19:21:53 -0400 To: freebsd-questions@freebsd.org X-Mailer: Apple Mail (2.753.1) Subject: Re: mysql connection through ssl tunnel X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Oct 2008 23:21:56 -0000 > Now I just need to figure out how to start it on reboot, but that > is something I've been meaning to learn, anyway, so I don't mind. I hope you guys will bear with me just a little more... I have spent the day trying to figure out how to create an rc script for autossh. Very cool, and not as hard as I'd anticipated. It is attached below. The script works perfectly *iff* I run it from the command line as a non-root user, like so: /usr/local/etc/rc.d/autossh start However, it does NOT work when executed by root. Instead, I get the following error message in /var/log/messages messages:Oct 21 19:01:38 on autossh[89267]: ssh exited prematurely with status 255; autossh exiting So (my understanding), autossh is starting, and tries to create the tunnel, but the tunnel creation fails with the unhelpful 255 error message. But only when executed by root. That's the puzzling part. I don't allow root logins on this server, but don't see how that could cause this problem.... I'm stumped. Any hints, much appreciated. -- John ---------------------- #!/bin/sh # PROVIDE: autossh # REQUIRE: LOGIN # KEYWORD: shutdown . /etc/rc.subr name="autossh" rcvar=`set_rcvar` start_cmd="${name}_start" stop_cmd=":" load_rc_config $name eval "${rcvar}=\${${rcvar}:='NO'}" command="/usr/local/bin/autossh" command_args="-M 20000 -fNg -L 33006:127.0.0.1:3306 admin@example.com" #pidfile="/var/run/autossh.pid" #AUTOSSH_PIDFILE="$pidfile"; export AUTOSSH_PIDFILE autossh_start() { ${command} ${command_args} echo "started autossh" } run_rc_command "$1"