This lua code used to work fine in an Edge scene but doesn’t now in Plus:
os.execute("ssh -i ~/.ssh/id_rsa -l user 192.168.0.73 /home/user/script.sh")
This is the part that’s stumping me. That same command from the Plus command line works fine:
ssh -i ~/.ssh/id_rsa -l user 192.168.0.73 /home/user/script.sh
I’ve tried that lua code in my scene and in Test Luup Code (“Sent Successfully”) but it just fails to perform. Not sure where to look to troubleshoot this.
Also you may need to copy the .ssh/known_hosts file to the new Vera. Without this the command may be prompting you to type “yes” to trust the remote machine, and there’s nowhere to type it, so it exits immediately.
[quote=“cybrmage, post:2, topic:191174”]Did you place the id_rsa key you are referencing in the command onto the plus??
also, try to use an absolute path to the id_rsa key…[/quote]
There’s nothing wrong with my ssh command. When executed from the Vera command line it works exactly as it should. It’s only when I surround it with os.execute(“”) as in my scene that it doesn’t work.
The absolute path suggestion was a good idea. Unfortunately it didn’t work. This is driving me batty because it used to work on my Edge.
Try using io.popen instead… I use it in the Caseta Connect and Wink Connect plugins without issue on VeraLite/Vera3/VeraEdge/VeraPlus…
I use a wrapper function:
function shellExecute(cmd, Output)
if (Output == nil) then Output = true end
local file = assert(io.popen(cmd, 'r'))
if (Output == true) then
local cOutput = file:read('*all')
file:close()
return cOutput
else
file:close()
return
end
end
then call it with:
shellExecute("ssh -i ~/.ssh/id_rsa -l user 192.168.0.73 /home/user/script.sh")
I was about to make a suggestion about putting your os.execute() Lua into a file and running it from the command line, then found an earlier post of mine that already talks about this. That whole thread resonates with this one, so it may contain more things to try.
Right now I’m thinking that either lua or ash has somehow changed in the new Plus, rendering my previously working scene code incompatible.
When I run an interactive Lua shell on my new Plus my code os.execute(“ssh -i ~/.ssh/id_rsa -l user 192.168.0.73 /home/user/script.sh”) works fine. Also, keep in mind that, as stated earlier, when I run just the full ssh command from the ash command line, it’s also successful. However, when running the whole thing from the ash command line I get this:
So unless I can figure out the correct syntax for os.execute and ash to work together I may have to go another route for my scene. I tried the same code in PLEG with the same results namely, unsuccessful.
Nono, put the Lua code into a new text file (say, try.lua) and then run the interpreter on there command line:
lua try.lua
What this scenario tests is if the environment is different for the root user via an interactive shell or inside of LuaUPnP. (Example: the HOME environment variable is different on VeraLite, which affects the expansion of $HOME and ~ in shells.) there may be other environmental differences such as path, uid or process limits.
Edit: oh, I see that you’ve already done much the same test by pasting the Lua code into an interactive session. The Lua-in-a-file test should behave the same.
So: it could still be the difference between HOME environment variables in a SSH interactive shell (/home/root) and LuaUPnP (/ on my Vera Lite). That’s going to affect the location of the known_hosts file as well as the id_rsa file, and is why people are adding the -y option to the SSH command line. Are you using the -y option?
When running “lua test.lua” with the content "os.execute(“ssh -f -y -i /root/.ssh/id_rsa hellovn@192.168.0.177 ‘/Users/hellovn/itunes/front_door.sh’”), it works fine. But the command os.execute does not work through a scene or PLEG.