I host hassio on a Intel NUC and it bothered me every time I wanted to shut down the UnRAID server I had to login to the UnRAID UI to do it. I could have paid £4 for the UnRAID app but that didn’t sit well when I just want to ask Google to turn off the server. It should be simple…
So after much Googling I’ve cobbled together this guide on how to turn on/off UnRaid from Hassio using RSA SSH and Wake on LAN. Most importantly it works from the Google Home
Be aware this guide assumes you have WOL configured correctly in the BIOS.
Hopefully some of you will find this helpful…
Let’s begin…
Create RSA Token Home Assistant CLI
Create UnRaid Directory in hassio dir
mkdir /unraid/
cd /unraid
mkdir .ssh
Generate the RSA Key
ssh-keygen
specifiy the location of the output to be /config/unraid/.ssh/rsa_key_name
Once an SSH key has been created, the ssh-copy-id command can be used to install it as an authorized key on the server. Once the key has been authorized for SSH, it grants access to the server without a password.
Once the key has been copied, it is best to test it
ssh -i /config/unraid/.ssh/rsa_key_name user@host
If the UnRaid server is rebooted before when next section of the guide is completed your SSH keys will get removed from UnRaid and you will need to start again from step 3.
Persistent SSH UnRaid
Check authorized_keys exists
ls /root/.ssh
Change permission of authorized_keys to 600:
chmod 600 /root/.ssh/authorized_keys
Create a script in /boot/config/ssh/setup_ssh_client.sh:
As a unRaid user myself I was wondering what your usecase is?
The only time I want to shutdown unRaid is when I am changing something, software or hardware on the server.
Can you share your usecase?
I use UnRAID for Plex data storage, Plex docker, downloads, and archive storage for Windows via SMB. Due to power costs and doing my part for the environment I don’t see a reason for UnRAID to be on 24/7 as it pulls considerable more power than the NUC, so it gets switched off when not in use. Eg. When everyone is asleep
@noodlemctwoodle Thank you so much for sharing this guide. But I have a problem. I do all the descripted things with the Addon SSH & Web Terminal. So the key creation, copy etc. worked pretty well. When I isssue the ssh connection and commands from this SSH Terminal all is working like a charme. But when I trigger the Switch or an Automation, the exact same command which works in the SSH Terminal, wont work.
So my assumtion is, that I have to create the key on the hass.io OS layer, but the ssh terminal is a docker container. So any hints or tipps, how I can access the hass.io OS layer to create the keys there? Or I am completely wrong?
@ph0b0s101 - Edit: Probably should have said Welcome to the Community
To be honest a lot has changed since I originally posted this guide.
I have rebuilt my UnRAID server on the AMD 3700X platform and consolidated all of my individual network appliances onto this server, therefore I am now unable to turn off UnRAID. It is now running Home Assistant Core and all of the containers associated with Home Assistant, my Firewall and, other home resources such as cloud backup and Plex
You could try and install SSH & Terminal add-on for hass.io this would give you shell access into the container.
Thank you for answering so quickly. That is what I already did. But it seems that the key is only available in the ssh addon, but when I issue a shell_command via a Switch or Automation, this will be issued on the hassio core system, and there are no ssh keys because they are in the docker container. So I think I have find a way to generate them directly on the hassio layer. Did you get what I mean?
Thank you so much for sharing this configuration. I am able to power on/off my UnRaid server with Siri, but it only recognize “Server” instead of “UnRaid-3700x”. Do you know it is possible to voice control by the server name?
Here you can specify the device and the Name for Google Assistant, which makes naming the devices very easy. Once you name the device in Yaml, it shows up on Google Home with the same name.
Hi,
thanks for this little guide. I use it to ssh to UnRaid and then execute some script there.
The Persistent SSH steps are no longer required from UnRaid 6.9
Home Assistant command line code doesn’t work but if i use terminal it works.
Unraid logs:
Connection from 192.168.1.36 port 35846 on 192.168.1.10 port 22 rdomain ""
Dec 8 17:28:49 unRAID sshd[1753]: Accepted key RSA SHA256: found at /root/.ssh/authorized_keys:2
Dec 8 17:28:49 unRAID sshd[1753]: Postponed publickey for root from 192.168.1.36 port 35846 ssh2 [preauth]
Dec 8 17:28:49 unRAID sshd[1753]: Postponed keyboard-interactive for root from 192.168.1.36 port 35846 ssh2 [preauth]
Dec 8 17:28:49 unRAID sshd[1755]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.36 user=root
Dec 8 17:28:51 unRAID sshd[1753]: error: PAM: Authentication failure for root from 192.168.1.36
Dec 8 17:28:51 unRAID sshd[1753]: Failed keyboard-interactive/pam for root from 192.168.1.36 port 35846 ssh2
Dec 8 17:28:51 unRAID sshd[1753]: Postponed keyboard-interactive for root from 192.168.1.36 port 35846 ssh2 [preauth]
Dec 8 17:28:51 unRAID sshd[1789]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.36 user=root
EDIT:
Regenerated the keys without password and set permit root login yes and now it works.