I am newbie with programming over this board... and I am wondering if there exists support for ssh client...
I downloaded an external ssh C library (libssh.org) and I have been trying to compile some examples from libssh: Chapter 1: A typical SSH session but I cannot compile that into the Arduino Yun sketches. :~
Any suggestion will be welcome, thank you in advance
Sorry for my English
I need to send a linux shell command via ssh to a remote host (virtual machine). That command would be, for instance, a shutdown command....
Now I think about to take some alternatives... Could I use the Process class available for run a "native" C program which perform the required task: log through ssh (providing user-passwd), then execute a linux shell command ?
That would be the normal way to perform a complex network task on the Yun, yes.
For SSH you don't need to provide a user password. Set up a public/private key pair. Have the private key stored on the Yun, and the public key authorized on the server, and ssh should be able to connect without requiring a password.
I wrote a test code using libssh and I could perform the task: the sending of shell command for shutdown a remote machine. But I wondering if is it possible to run that code through... Process.runShellComand("shutdown_remote_machine");
where "shutdown_remote_machine" is the C binary source which executes that task...
Can I add this binary source code from "Add file..." in Sketch tab of Arduino IDE?
How can I access it from the sketch code .ino?
Thanks you for share your knowledge!
I see this Plan B like a good alternative... but I am so newbie and I wonder how must I install and compile this package into my Arduino Yun?
Do I need access to the Arduino Yun console and install/compile this package? Then I will be available to write your example in the sketch .ino
Is it ok?
#!/bin/sh
empty -f -i in -o out ssh username@foo.bar.com
#empty -w -i out -o in "ogin:" "root\n"
empty -w -i out -o in "assword:" "TopSecret\n"
#empty -s -o in "who am i\n"
empty -s -o in "touch newfile\n"
empty -s -o in "exit\n"
I've followed your guide to setup/run empty and all was well until...
when I run my script with "empty" lines I get two times the same error:
Fatal open FIFO for writing: in: No such file or directory Fatal open FIFO for writing: in: No such file or directory
This is my sh script:
autossh.sh
#!/bin/sh
empty -f -i in -o out ssh arturo@rudeboy
empty -w -i out -o in "assword:" "654321\n"
empty -s -o in "touch newfile\n"
empty -s -o in "exit\n"
I am thinking to take your Plan B... Now I downloaded sshpass doing wget http://colocrossing.dl/ ....
but when I try to ungzip the tar.gz file nothing occurs... the command line stays waiting...
arrudeboy:
...
I am thinking to take your Plan B... Now I downloaded sshpass doing wget http://colocrossing.dl/ ....
but when I try to ungzip the tar.gz file nothing occurs... the command line stays waiting...
...
The tar comes with Yun is from busybox's shrink down version. Upgrade full version tar.
It was enough with following the Plan C...
I would could sending the shutdown/reboot command to remote machine and it is done perfectly
Now I have to do that with a virtual machine which is the host that emulates a cluster central node...
I did set up port forwarding between the host and guest... but I cannot accomplish the ssh sending command via "empty"... perhaps I need to add new port forwarding between ip:port of Arduino Yun and ip:port of virtual machine...
But I am thinking about the Plan B into the Plan C... lol
wow It is very abstract !
The majenko's Plan A is only kosher way to get job done, since shutdown/reboot is required root access right, the password is not very safe to hardcode.