Openhab to access other server via ssh to execute script

You need to generate ssh keys as the openhab user and then copy them across to the target server. I use the following to do this to access a number of other devices to execute scripts locally stored on the remote server.

sudo -u openhab ssh-keygen -t rsa

then

sudo -u openhab ssh-copy-id -i /var/lib/openhab2/.ssh/id_rsa.pub user@hostname

You can then test and confirm ssh key access with

sudo -u openhab ssh user@hostname and you should have access.

Note: I’ve assumed an openhabian install on the Raspberry PI. If not then change /var/lib/openhab2/ to whatever the home directory is for your openhab user.

5 Likes