How to start up and shutdown a Netgear ReadyNAS from VERA

without the '-y" it works.

Not ideal, but could you try it with the -y again, but two -y this time? Just to see what that does.

Same message,"Failed loading keyfile ‘-y’ "
image

Ok, we can’t be far away, try this in LuaTest

local command = io.popen("ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown" 2>&1)
local response = command:read("*a")
print(response)

This should tell us a bit more about what’s happening and any errors etc.

I’m getting some sort of syntax error:

so, I moved the perenthesis and ran the code again. This was the output:

So just to confirm

When you send the ssh command directly (via putty) at the command line it works ?
But when you send it via the Vera UI/LuaTest it doesn’t ?

Do you have the yes/no prompt via putty ?

UPDATE

Doing a quick search, there are examples online of adding the following -o ‘option’ to the ssh command. Now it won’t stop the host file error message , that will need someone more knowledgeable than me, but it may allow it to work (as it’s an IP you trust)

-o StrictHostKeyChecking=no

Which would make it now…

ssh -i -o StrictHostKeyChecking=no /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1

correct.
logging into putty via root and password then sending this:
ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 ‘rnutil rn_shutdown’
Does shut down the NAS.

Sending the following from the Vera UI does NOT work:

os.execute( " ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 ‘rnutil rn_shutdown’ " )

Note - UI says it’s sending the command but the NAS is not responding.

Sending the below via **LuaTest 1.7 Sneds with no erro but does Not shut downt he NAS

local command = io.popen(“ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1”)
local response = command:read(“*a”)
print(response)

What did this command do ?

this:
image

And what error did you get when sending that command via the Vera UI ?

I’m assuming I needed to wrap it like this:
os.execute( "ssh -i -o StrictHostKeyChecking=no /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1’ " )

That did nothing. UI says it sent the command but it did not shut downt he NAS

Does the following still result in that y/n prompt ?

local command = io.popen("ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1")
local response = command:read("*a")
print(response)

If so then an option is the ‘yes’ command, not something I know or use, but seeing as you are using it to shutdown, it might be worth a try…

this is what i got:

If you are ok to try it, let’s give the yes command a go.

I’ve not used it before but it looks like we just put ‘yes |’ at the beginning (BTW, the ‘|’ character/symbol i used with yes is a ‘vertical bar’, not a letter - e.g a capital I (i) or little l (L)

local command = io.popen("yes | ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1")
local response = command:read("*a")
print(response)

that worked!

Great news !!

It’s not perfect, but at least it’s functional - plus it saved you some $$$

you deserve the cash. Not sure if you can PM me somehow, but I’d like to pay you.
Also - one question, Do I need to generate a different key for each NAS or can I use the same key I used on .86?

Hi @Patrick_Beauchemin - The key is generated from your Vera, so if it’s all against local devices, on your own local network, then the same key should work. You just have to create the trust between the two devices…

Also - we didn’t explicitly say it above, but the code that I should be sending now and calling via a scene should be:
os.execute(“yes | ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1”)
That was based on this working:
local command = io.popen(“yes | ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1”)
local response = command:read(“*a”)
print(response)

Is that correct?
-Patrick

You should just be able to get away with this.

os.execute(“yes | ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown)

And use the other if you encounter any problems and need to see the messages that come back

Alternatively, if you use the following, it should log any messages to the Vera log file.

local command = io.popen("yes | ssh -i /etc/dropbear/dropbear_rsa_host_key root@192.168.1.86 rnutil rn_shutdown 2>&1")
local response = command:read("*a")
luup.log(response)