Supplying password to openconnect started via start-stop-daemon

Solution 1:

I ended up creating a wrapper script for the openconnect, which loads the password and pipes it to the stdin of the openconnect daemon, IOW:

#!/bin/bash

PASSWD=`/bin/cat /etc/openconnect/passwd`

/bin/echo $PASSWD | /usr/sbin/openconnect $@

And start-stop-daemon invokes this wrapper instead of the openconnect.

Solution 2:

openconnect (at least in version 5.02) does allow you to provide the password on STDIN.

From the manual:

--passwd-on-stdin

    Read password from standard input

So you can use:

echo 'password1' | openconnect --passwd-on-stdin ...