![]() |
Script to open SSH connection and run commands on other Linux device
Hi!
I use a NSLU2 (NAS-System) which runs linux (debian) with a usb-controlled multiple power socket (Gembird) to control the light in my living-room. Works fine. (At this time I control it with a PHP-based webpage on the NSLU) Now i want to switch the sockets without this (slow) webpage. My idea was to create a script which connects via SSH from the N900 to the NSLU and then run the needed commands. When i connect manually with XTerminal over SSH i get a prompt to enter my password. After this i can run the command. How can i put this in a script? Is this automation possible with a "password-based-authentication?". Or do i need certificates or something like this for authentication. My second question: How can is put a link to this script to my "program menu" or to a homescreen. Thank you! |
Re: Script to open SSH connection and run commands on other Linux device
For logging in, use public key authentication (google is your friend). It really isn't hard to setup, create a pair of keys and put the public one on server and the private one on the device, plus change a line in the server config.
For executing a command upon login, just use ssh user@host command (so you can create a script on the N900 that logs on to the nslu2 and runs a script to toggle the lights). |
Re: Script to open SSH connection and run commands on other Linux device
Thanks for your fast response!
Sounds manageable to use public key authentication. I'll try it! Do you know wheter it's complicated to add an shortcut or something to the homescreen / menu? |
Re: Script to open SSH connection and run commands on other Linux device
RouterRebooter: Think about n900 like about normal linux machine.
here it is: http://rcsg-gsir.imsb-dsgi.nrc-cnrc....et/node31.html after this you can use command like this: ssh username@IPofMachine Commands for execution.... If you need step by step instruction, I can write it in 2 hours (now don't have time).... |
Re: Script to open SSH connection and run commands on other Linux device
Quote:
|
Re: Script to open SSH connection and run commands on other Linux device
Quote:
I'm pleased about your helpfulness - really great! I'll try to establish the connection with the method form your link. If I've further questions, i put it in this thread :) Thanks! Does anyone know how it's possible to add an shortcut (to run the script on N900) or something to the homescreen / menu? |
Re: Script to open SSH connection and run commands on other Linux device
Quote:
"ssh username@192.168.X.X /path/commandfile.*" command? |
Re: Script to open SSH connection and run commands on other Linux device
Hi RouterRebooter,
The info to make a desktop icon to run an ssh command can be found in this post: http://talk.maemo.org/showthread.php?t=35858 I used it to run WOL (an installed app on my Linux device) via SSH. the icon method allows you to run one command. but you can make a script to run many commands. the cool thing is you can also make your own icons too. i am a newbie to Linux and the terminal but with minimal experienced i achieved success. a program i found essential was WinSCP it gives you a windows GUI like file manager to you n900 after you have installed SSH Server. I had to install a new program on my n900 and restart before my icons showed up. I now have several custom desktop icons that run SSH scripts. good luck tim ps. if you read the whole post i ask all the newbie questions. |
Re: Script to open SSH connection and run commands on other Linux device
Quote:
Sounds good! Now i only need time to read and test it - I hope tomorrow ;) |
Re: Script to open SSH connection and run commands on other Linux device
Step by step protocol for create passwordless connection:
Quote:
Quote:
|
All times are GMT. The time now is 23:10. |
vBulletin® Version 3.8.8