Viswa
Viswa

Reputation: 171

How do I reboot the remote system via python script?


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 [email protected]. 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.

Upvotes: 0

Views: 2654

Answers (2)

user2074347
user2074347

Reputation: 31

You can use paramico for access to ssh via python

Upvotes: 1

albert
albert

Reputation: 11

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.

Upvotes: 0

Related Questions