I have a Gen8 Microserver and would like to be able to be able to boot the machine using a ILO command sent to the server. The current ILO integration is sensor only:
I have successfully been able to turn it on and off using the commands below, logged in as root to Hassio
Thanks its unfortunately outside of my expertise at this stage so hoping there could be someone looking to do the same thing a little more knowledgeable
The joys of working with Home Assistant are that you get to learn new things. Can you ssh into the iLO interface and turn the server on? If you can, you should be able to use expect to create a VERY simple script to do this from HA.
OK after a number of hours of googling and experimenting I am very close to getting this to work. I have a script which when I SSH in works perfectly, however via a script in HA it gives me an error:
# Turn on Server
server_on:
alias: SERVER ON Script
sequence:
- service: shell_command.server_on
server_off:
alias: SERVER OFF Script
sequence:
- service: shell_command.server_off
I have the private key (exported as Open SSH key from PuttyGen) in the /config/ssh/ dir with no extension and CHMOD to 600.
Sorry I appreciate these are probably basic linux issues!
not sure if I have the right user on Hassio but my users are:
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
man
postmaster
cron
ftp
sshd
at
squid
xfs
games
postgres
cyrus
vpopmail
ntp
smmsp
guest
nobody
managed to get this working in the end. For anyone else interested, I gave up with Hass.io. Hassbian has a less complex way of managing users and permissions and the only way the n00b I am could get it to work.
This example relates specifically to turning on and off a HP Microserver via ILO but in principle can be used for any SSH script requiring a private key.
Also not that this assumes you already have the RSA key installed on the server, which I managed to find in a googled tutorial for ILO, and basically requires you to upload one from puttygen.
in this example client_ip = the ILO server IP address
to login to your home assistant account type: sudo su -s /bin/bash homeassistant
navigate to /home/homeassistant/.homeassistant
create a ssh directory using mkdir .ssh
open your samba share in windows \\ipaddress
navigate to .ssh directory and copy your private key (OpenSSH format) - i.e. privatekey_filename
Test your script using the format: ssh -i "/home/homeassistant/.homeassistant/.ssh/privatekey_filename" privatekey_username@client_ip "power off"
where privatekey_username is the username if the key installed to your client
server_on:
alias: Server ON Script
sequence:
- service: shell_command.server_on
server_off:
alias: Server OFF Script
sequence:
- service: shell_command.server_off
Reboot and this script will show in HA. The same can be done for Server Off.