I use OPENHAB2 SNAPSHOT offline, recent build 648.
I am needing to run a remote command on a Linux platform but do it using certs for auth.
Since the ‘openhab’ user that OH2 runs under doesn’t have a login shell, I built the certs and the script file in the /home/pi folder with the certs being in /home/pi/.ssh When logged in as ‘pi’, the script runs great, however; OH2 doesn’t run it.
I have tried ‘su -l pi /home/pi/script.sh’ thinking that it would change the appropriate ENV variables to read the cert.
su -l pi -c /home/pi/script.sh
Otherwise I think it just drops back to the original user.
Also, for bug finding things like this, I tend to find doing something like:
env > /tmp/debug.$$
near the top of the script helps ($$ changes to the PID of the script when it is run). This will dump the environment to a file for you to look at. This way you can make sure its using the correct settings (and user)
Also, thinking about it, I’d use sudo instead of su.
sudo -u pi -i /home/pi/script.sh
With the correct permissions set in /etc/sudoers of course.
Thank you, the sudo -u pi worked
Just copy your ~pi/.ssh folder to ~openhab/.ssh and change the ownership and permissions to openhab:openhab 0600.