How to start up and shutdown a Netgear ReadyNAS from VERA

Appparenly newer version of readynas frimware wont allow simple curl to shutdown NAS units. Something about new security update and having to get a token first.
I found someone who overcame this and implemented on Homeassistant:

but wondering how to do this in Vera?
Regards,

Have a look here , this should help…

Thank you, but OMG. I started reading the threads and my brain hurts. I can’t tell which parts I need, what is the solution. Can someone distill the solution for me?

I think this is the place to start…

perhaps someone might just be willing to make this work for me (along with detailed step by steps) and I can paypal them for their time. I was thinking maybe $100.

Hi Patrick,

How did you get on ?

It’s far from me to say anything if someone’s available to help (at a cost), but if not, the goal of this/any forum is to create a community that tries to help people.

So putting the money to one side - as I was engaged in that other thread too, it all seemed quite straightforward in the end.

Have you tried to do anything yet ?

For the turning off/waking up the older NAS units it was some simple trial and error to get the one line of Lua code to work. But this a completely different thing. It looks much more technical than I’m comfortable with (it’s a bit over my head or maybe I’m over thinking it :)). honestly, I’m super paranoid about screwing up my devices.
I feel like I could spend a huge amount of hours trying to figure this out and quite honestly, I’d rather pay someone to solve it for me.

Completely your call, the link/guide that you shared in your original post looks like it has almost everything you need, other than you will require a key generated from Vera, rather than as the example does get it from a HomeAssistant (Docker) container.

The link I shared had a post on how to generate the key and send it to a raspberry pi, so in your case you could just send it to your ReadyNAS (or into a share) instead to them find and import.

If you are concerned about the ‘dropbearkey’ command then just look here - dropbearkey: create private keys for the use with dropbear(8) or dbclient(1) - Linux Manuals (1) where you can see the -y and -f options are just coping the key to a file, grep is then getting that information from the file and then - it goes on to ssh onto the pi, create a .ssh directory (if one does not exist) and then it write the information into ‘ .ssh/authorized_keys’

Sadly I don’t have a ReadyNAS to actually test this - (I used to have Duo many years ago), anyway I don’t think there’s much you can do wrong here, but there are naturally disclaimers at this point :slight_smile: as I’ve not done this before and for you to do this, it will require you to SSH onto your Vera.

Below is what I have just done to create a key file and save it locally on the Vera, have a look and check the contents (validate with ReadyNAS or that HA poster what should be in the key file etc.) (adjust accordingly) and then when you’re happy Import it in to your NAS

BusyBox v1.19.4 (2019-12-04 15:22:44 UTC) built-in shell (ash)
Enter 'help' for a list of built-in commands.

root@MiOS_50103712:/# ls
1                  dev                foo                mios_constants.sh  proc               sbin               tmp                www
5                  etc                lib                mnt                rom                storage            usr
bin                ezmi               mios               overlay            root               sys                var

root@MiOS_50103722:/# dropbearkey -t rsa -f /key.txt

Generating 2048 bit rsa key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc22EAAAADAQABAAABAQCSn8uiwziOKm752rB9jbyneWz7emEQDxW5XJ9cCf9hFBgfX9+4/8XWowHUxzyFI+O91npMvPoO4vMDF56YQ8NnPm7K+DtTPm01ULUGsUfMuMk5qt5CGyyBZZ6z/93939939300/w5QpDVHaaJkrHJThJTP9cOFvf9S8S6rJ2m1M3OigYzEa99IzWoVcVC4sARYGlZGNKEW5MVimDnMHHOC/GZUGZE9+HPFUEx+xP+4ko2GXKjSm10foZh/Gc6bwtlOxbG5lsx2Sq5TysH5p3DTTeh9l82US34eK/Wu+iGGRN9/APumImnGPTiSm6lT9JnU3hr5NKL9xzWweYKz root@MiOS_50103722
Fingerprint: sha1!! 39:76:1e:cc:00:90:da:23:7d:00:4a:6b:2d:ec:f0:d0:9b:a5:bc:20

root@MiOS_50103722:/# ls
1                  dev                foo                mios               overlay            root               sys                var
5                  etc                key.txt            mios_constants.sh  proc               sbin               tmp                www
bin                ezmi               lib                mnt                rom                storage            usr

If it is just the public key portion, then you may just be able to copy and paste from the screen and place it in a text file and import.

so it took me 30 minutes to figure out that I needed somethgn called putty, how to root access (find the password) etc. Now I spent another 20 minutes to try to get the list of directories but all i get is "l’

That’s OK, you are just in the home folder, which by the looks of it just has a file/directory called ‘1’ in there.

If you type ‘ cd / ‘ you will then go to down to the bottom level where you can see more files /folders - but you don’t necessarily have to go there, you can just run the command I shared from either location.

okay - I did that. Now Ihave a key.txt folder on the vera. What’s next?
BTW - On the Readynas, when I enable SSH, it provides me a SSH public_ssh_key-nas5 (1).txt. Is that what needs to go inside the folder on the vera?

Hi Patrick

As your NAS has it’s own process for this, I’m going to have to assume a few things, such as a) you are doing this from a PC and b) the upload feature on the NAS will deal with the processing and anything else like file permissions it might need…

With that in mind, this is what i would do,

  1. SSH on to your Vera and go to the root folder via ‘cd /‘ and then run this command
dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key | grep -F ssh-rsa >> pubkey
  1. Use WINSCP to access Vera (using your Vera SSH credentials ) and locate the ‘pubkey’ file you just created, and copy it over to your PC

  2. Upload that pubkey file to your ReadyNAS following the instructions in the GitHub / Home Assistant screenshots you shared earlier.

okay - I’ve done all that so, now what? How do I execute code on vera to shutdown the NAS?

Ok, good, now log into Vera via ssh and try something like the following, using the name of an account you have set up on the NAS that can use ssh, and update it to use the ReadyNAS’s IP address - and then run any terminal command to see if it works e.g

" ...on the Vera, you should be able to: `ssh pi@192.168.1.101 'ls -l'`  (or whatever command you want) without password...."

‘ls -l’ is a command that will show you the directory/folders on the ReadyNAS .

When you have that working, try something like the following to shutdown command.

ssh admin@192.168.1.111 sudo shutdown -h now

When you have that working, you can then make the call via the Vera UI in a scene, by wrapping the same command in os.execute(‘command-here’)

Okay, I was able to run this from Putty:
‘ssh root@192.168.1.86 rnutil rn_shutdown’
and it turned off the NAS…Nice!!
now what? I just tried testing the following: “os.execute(‘ssh root@192.168.1.86 rnutil rn_shutdown’)”
from the Vera Test Luup code (Lua) UI and it "gave me an error.

Great news !!

Ok, now Vera is very fussy about the type of apostrophes and quotes/speech marks you use, don’t use the curly ones, use the straight ones, plus the placement/separation will be important too.

Try this…

os.execute( ' ssh root@192.168.1.86 rnutil rn_shutdown ' )

or this

os.execute( "ssh root@192.168.1.86 'rnutil rn_shutdown' " )

unfortunately, neither one worked.

Hummmm…

Did you get any errors this time ?

no, i did not. it says it’s sending the commands