I am getting a little bit into home automation and have been implementing bit by bit small actions and automations into my Home Assistant interface. I am sure there are some people here have messed around with it but if not the question is independent so the answer for proficient linux users is likely a simple one....for me I am still learning.
In my Home Assistant (installed on a Rasppi) I have figured out how to create a "switch" in the configuration.yaml which sends a WOL signal using the MAC address of my OMV installation
- platform: wake_on_lan
name: "OMV Server"
Ok so far so good. It wakes up the OMV server and the switch registers the the server is on by the highlighted symbol. That was of course easy.
Now for how can I integrate a shutdown command by toggling the switch to the "off" position. Here is where I am a little lost after digging the the OMV and Home Assistant forums, but so far I understand the easiest and best way to achieve this is through generating an RSA key on the Home Assistant Rasppi and transferring that to OMV, thus allowing a "one-liner" shutdown command. I am unsure of where to put these keys on the OMV side and before I go and break something I though I would throw this out there if anyone could correct or refine my steps:
1) using root account on Rasppi (with Home Assistant) generate RSA Key: ssh-keygen -t rsa
2) save key to ~/.ssh. This generates apparently two files- a id-rsa and and id-rsa.pub
3 login to OMV: ssh email@example.com (or do I login as root?)
4) cp id-rsa.pub (or is it the id-rsa without the .pub?) to OMV in /root/.ssh
The shudown command in the configuration.yaml should then be: "sudo ssh firstname.lastname@example.org poweroff"
I am little lost if I need a subfolder in the .ssh directory 'authorized_keys'. I had a look in the the root/.ssh of OMV and there are already two files with the same id-rsa and id-rsa.pub, so how I differentiate the new key to authenticate with the user account on Home Assistant?
Thanks for the help!