# [SOLVED]autossh init script reporting failure but succeeding

## eponymous

Hi,

I have the following script which runs at startup:

```
     depend() {

             need net

             after dns

     }

     

     AUTOSSH_PIDFILE=/var/run/autossh/autossh-tunnel.pid

     AUTOSSH_BINARY=/usr/bin/autossh

     AUTOSSH_MONITOR_PORT=20000

     USER=scponly

     HOST=scponly@myhost.com

     # For reverse access

     FORWARD_OPT1="-R 2222:localhost:22"

     # CCTV camera

     FORWARD_OPT2="-L 5540:10.0.0.1:554"

     # CCTV camera

     FORWARD_OPT3="-L 5541:10.0.0.2:554"

     # HTTP proxy

     FORWARD_OPT4="-D 1080"

     

     start() {

             export AUTOSSH_PIDFILE

             ebegin "Setting up SSH tunnel(s)."

             start-stop-daemon --start --user "${USER}" \

             --name autossh-tunnel \

             --pidfile "${AUTOSSH_PIDFILE}" \

             --exec "${AUTOSSH_BINARY}" -u "${USER}" -- -M "${AUTOSSH_MONITOR_PORT}" -f "${FORWARD_OPT1}" "${FORWARD_OPT2}" "${FORWARD_OPT3}" "${FORWARD_OPT4}" -N "${HOST}" 

             eend $? 

     }

     

     stop() {

             ebegin "Closing SSH tunnel(s)."

             start-stop-daemon --stop --user "${USER}" \

             --name autossh-tunnel \

             --exec "${AUTOSSH_BINARY}" \

             --pidfile "${AUTOSSH_PIDFILE}" 

             eend $? 

     }
```

If I run the script manually *after* startup, everything works fine with no errors reported. The scponly user has access to /var/run/autossh to make the pid file.

However as soon as I do an:

```

rc-update add autossh-script default

```

... and reboot I get this message in rc.log (same message is in /var/log/messages):

```
      * Setting up SSH tunnel(s). ...

      * start-stop-daemon: did not create a valid pid in `/var/run/autossh/autossh-tunnel.pid'

     [ !! ]

     * ERROR: autossh-tunnel-tuxfs-v2 failed to start

```

But it does create the file with the correct PID and autossh works fine and I can use the tunnel!

What is going on here?Last edited by eponymous on Wed Feb 22, 2012 8:49 am; edited 1 time in total

----------

## eponymous

If it helps I have the following configuration for scponly in my /etc/passwd:

```
scponly:x:105:101:added by portage for scponly:/home/scponly//:/usr/sbin/scponlyc
```

and it doesn't allow me to have a login shell which could cause issues perhaps?

----------

## eponymous

Ok solved. The permissions on the /var/run/autossh directory were at fault. I re-created the directory as root and did a "chown -R scponly:scponly autossh" and it has set the permissions fine.

----------

