0


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.

2

2 Answers 2

1

You can use paramico for access to ssh via python

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

And you will also disable access to anyone who had via ssh keys... You should not overwrite authorized_keys/authorized_keys2
A better way to add SSH key is to use the ssh-add utility. If appends a key to authorized_keys -- not replacing it...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.