I need to reboot all my remote systems from my Ubuntu 10.04 system by every 3 hours once, So I decided to write python script for reboot my remote Ubuntu 10.04 systems.I know how to reboot the remote system via terminal ssh root@192.168.1.xx
. But, don't know how to implement it in python script.
*Note:*when i reboot the remote system via terminal it prompts the password. How to reboot my all remote systems through python script without asking password. If you know let me, it is very helpful to me.
Asked
Active
Viewed 2,479 times
0

Viswa
- 151
- 1
- 2
- 7
-
1Will paramiko work? http://stackoverflow.com/questions/3586106/perform-commands-over-ssh-with-python – Brent Washburne Jun 14 '13 at 04:28
-
Here's a direct method using subprocess + OpenSSH: https://gist.github.com/bortzmeyer/1284249 – Brent Washburne Jun 14 '13 at 04:30
2 Answers
0
If you want to reboot remote systems without password, you need to configure the SSH key for the remote systems. First, you need to create a SSH key on the system you run your python script.By using
$ ssh-keygen -t rsa -P ""
Then, you change the name of your SSH key file
$ mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
Now, you can copy you SSH key to the remote systems.The path is ~/.ssh/
$ scp ~/.ssh/authorized_keys user@remote_ip:~/.ssh/
Job is done, Now you can login remote systems without password, so is your python script.

albert
- 11
-
And you will also disable access to anyone who had via ssh keys... You should not overwrite authorized_keys/authorized_keys2 – mishik Jun 14 '13 at 04:53
-
A better way to add SSH key is to use the `ssh-add` utility. If _appends_ a key to `authorized_keys` -- not replacing it... – Sylvain Leroux Jun 14 '13 at 07:36