|
2010-01-06
, 17:22
|
Posts: 287 |
Thanked: 127 times |
Joined on Oct 2009
@ Sweden
|
#2
|
The Following User Says Thank You to floffe For This Useful Post: | ||
|
2010-01-06
, 17:29
|
Posts: 92 |
Thanked: 9 times |
Joined on Nov 2009
@ Germany, Bavaria
|
#3
|
|
2010-01-06
, 17:34
|
Posts: 207 |
Thanked: 119 times |
Joined on Nov 2009
@ Pittsburgh, PA, USA
|
#4
|
The Following User Says Thank You to mikhmv For This Useful Post: | ||
|
2010-01-06
, 17:43
|
|
Posts: 531 |
Thanked: 79 times |
Joined on Oct 2006
@ This side of insane, that side of genius
|
#5
|
The Following User Says Thank You to brendan For This Useful Post: | ||
|
2010-01-06
, 17:45
|
Posts: 92 |
Thanked: 9 times |
Joined on Nov 2009
@ Germany, Bavaria
|
#6
|
|
2010-01-06
, 17:49
|
Posts: 92 |
Thanked: 9 times |
Joined on Nov 2009
@ Germany, Bavaria
|
#7
|
this assumes that the "Commands for execution" reside on the remote machine.
|
2010-01-06
, 17:49
|
Posts: 352 |
Thanked: 231 times |
Joined on Jul 2008
@ Vancouver
|
#8
|
The Following User Says Thank You to timwatt For This Useful Post: | ||
|
2010-01-06
, 17:58
|
Posts: 92 |
Thanked: 9 times |
Joined on Nov 2009
@ Germany, Bavaria
|
#9
|
|
2010-01-06
, 20:22
|
Posts: 207 |
Thanked: 119 times |
Joined on Nov 2009
@ Pittsburgh, PA, USA
|
#10
|
1. install packages OpenSSH (client, if you want server too) and rootsh on n900.
2. open x-term
3. "sudo gainroot" (or just "root")
4. "ssh-keygen -t rsa" (create keys)
Use everything by default (press enter)
5. $ "cd .ssh" (go to folder .ssh)
6."cp id_rsa.pub N900_id_rsa.pub". it make copy key file to N900_id_rsa.pub. You can use any name. It is helpful if you have many servers.
7. "scp N900_id_rsa.pub ServerUserName@IPofServer:/PathToUserHomeOnServer/.ssh/" If you are going to connect like root it will be:
"scp N900_id_rsa.pub root@IPofServer:/root/.ssh/". you will be asked for password. it will copy your password file on server
8. "ssh ServerUserName@IPofServer". Connect on server. You will be in home folder of User
9. "cd .ssh" Go to folder .ssh. For root it will be /root/.ssh
10. "ls" Get list of files in folder. You should look for "authorized_keys" or "authorized_keys2" file. I don't know why but some servers have "authorized_keys2" file by default. It is not necessary to exist.
11. "cat N900_id_rsa.pub >> authorized_keys". this will attach text from N900_id_rsa.pub file to the end of authorized_keys. If in previous step you find file "authorized_keys2" you should use "cat N900_id_rsa.pub >> authorized_keys2".
12. "exit". Disconnect
13. "ssh ServerUserName@IPofServer" You should connect to server without password. If you asked for password that mean something wrong here.
1. Open any text redactor which can save text "ascii" files. on n900 it could be "leafpad" (starting from menu) or "nano" and "vi"(for x-term). You should install packages before. I personally more prefer nano. But you can use windows Notepad.
2. put first line "#!/bin/sh"
3. Add all commands which you type in terminal when connected to server.
4. Save file like "ascii" for example it will have name: "commandsFile"
5. open x-terminal
6. "scp commandsFile ServerUserName@IPofServer:/usernameHomeFolder/" for root it will be "scp commandsFile root@IPofServer:/root/". this will copy you file to server. Should be without Password (if you copy from device which you used in "protocol for create passwordless connection")!!! If you use other user than root probably will be better to store this file in "/usr/bin" but it is on your choice....
7. "ssh UserName@IPofServer chmod ug+x /usernameHomeFolder/commandsFile" Make this file executable.
For running this script you should use:
"ssh UserName@IPofServer /PathToFile/commandsFile"
The Following User Says Thank You to mikhmv For This Useful Post: | ||
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!
Last edited by RouterRebooter; 2010-01-06 at 18:01.