Register
It is currently Fri Oct 24, 2014 10:15 pm

reboot servers based on list


All times are UTC - 6 hours


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 PostPosted: Tue Feb 01, 2011 12:13 pm   

Joined: Tue Feb 01, 2011 11:53 am
Posts: 2
Overview of what I am looking for. Reboot a set of Red Hat servers remotely using SSH in a lab environment. I am new to scripting in Linux and really do not know where to start.

Requirements:
Access a set of Red Hat servers via SSH based on a list of IP addresses or hostnames and have them reboot. I also need to add a delay or sleep where the servers are rebooted every so many minutes or hours.

this is a lab where I need to reset servers every x # of minutes.

All servers have the same root password and SSH keys are not required but I am not against using them either.


Top
 Profile  
 PostPosted: Tue Feb 01, 2011 1:38 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
Hi,

How do you get servers list?

Do you want servers to be rebooted "as soon as" the script starts?

You should use keys to connect through ssh to servers; any other way is not safe.


Top
 Profile  
 PostPosted: Wed Feb 02, 2011 11:19 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Should use SSH keys for sure. The only other "safe" option I know of is Perl's Net::SSH, but even then you've got passwords stored in plain text.

What have you got so far? Share it with us and we'll help you get it going!

-J


Top
 Profile YIM  
 PostPosted: Sat Feb 05, 2011 12:39 pm   

Joined: Tue Feb 01, 2011 11:53 am
Posts: 2
Well the list will be manually completed txt file with IP addresses or host names. I can use keys which I have no issue with. This is a lab environment only though so in this case storing passwords in plain text is not an issue since all the passwords on these boxes is password.

shutting down the servers as soon as the script starts to execute the list is what I am looking for. This is a test environment so we have 4-16 servers up at one time or even more in some cases that need to be shutdown so we can configure for the next test.

Shutting these servers manually is a time consuming process so scripting the shutdown is a time saver for us.

I have a script that does this in windows already. I am new to scripting in general.


Top
 Profile  
 PostPosted: Wed Feb 09, 2011 3:52 pm   

Joined: Thu Sep 16, 2010 3:57 am
Posts: 11
You can use "onal" to execute commands on remote machines

First you need to use SSH keys for users from the list

Code:
cat list_of_machines.txt

login1@10.0.0.2
login2@192.168.0.1

Olso users must have rights to sudo commands without password

Example of using onall

Code:
onall -p -f /list_of_machines.txt 'sudo reboot'

or
Code:
echo host1 host2 host3 | onall -p 'my remote command'


Top
 Profile  
 PostPosted: Sat Apr 09, 2011 7:17 pm   

Joined: Tue Dec 11, 2007 10:21 pm
Posts: 20
or is easy to build a bash script which will use the command shutdown -r now.

put the bash script as a shell to a sudo user and once the user is logged into your machine the server will reboot :)

i made such script once however i cannot find where i saved it.

my history i had a lot of dedicated servers , so we had a panel where we set reboot option i build a bash script which had to run shutdown -r now command , and i set it to a user which i added the group of shutdown and wheel , once our users apply reboot button the script was log into he;s server the user we added and exec the reboot .


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP