Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Lan shutdown script problem for RHEL5u5

    I am new too. I have some experience using scripts but am no where near proficient. I have used the ssh shutdown script and it works great one machine at a time but like Hudak998 I have more than one machine. I actually can have as many as 200 machines online at any given time. I have a sript I have been trying to get to work and maybe someone here could help me figure out why it does not work. As you can read (below) 2 integers are required which is a range of machines. However it returns "machine_name is down". In reality the machines are up and I can ping them.
    HTML Code:
    #Author :Romaddave
    #Date : 5-3-2012
    #Purpose : Shutdown LAN PCs
    #Check if 2 parameters exist
    if [ $# != 2 ]
    	echo This script requires 2  integer parameters
    	exit $ERROR
    while [ $MIN -le $MAX ]
    	ssh -o NoHostAuthenticationForLocalhost=yes root@192.168.9.$MIN shutdown -h now > /dev/null
    	STATUS=`echo $?`
    	if [ $STATUS = 0 ]
    			echo view$MIN is Shuting down
    			echo view$MIN is not Responding
    	let "MIN +=1"

  2. #2
    Thanks to whomever put this in HTML for me. Hope I haven't broken any rules. This is the first forum I have ever been a part of and I look forward to sharing if I can.

  3. #3

    LAN shutdown

    OK, using a new script and network wide shutdown now works. Only problem is I am asked for the root password for each host machine selected for shutdown. So that is 145 times I have to put in the password. Not time efficient. Quicker if I just go around and power down all the machines manually.

    The rsa keys match so I can't figure out why it's asking for a password (please read the script before replying to this). In the script I am using:

    "ssh -o NoHostAuthenticationForLocalhost=yes root@view$MIN shutdown –h now > /dev/null" This should bypass the requirement for a password - right?

    I am using a new script that I inherited from the previous admin who was better than me at shell scripts. What I posted before was my attempt - and it failed. I found this one buried in archived files. I have attached the text file here for someone - anyone - to look at. Please someone respond. Because both scripts look the same to me. LAN-Shutdown.txt
    Last edited by romaddave; 03-17-2012 at 04:52 PM. Reason: missing information in post.

  4. $spacer_open
  5. #4
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    The Keystone State
    Have you thought about using ssh-keys for this?
    What you would do is generate a key for root and then copy the public key to all the servers.
    Then you could shutdown the servers with:
    ssh <ip> shutdown -h now
    and the server would be shutdown without the need for the password as the key would be the authenticating method.

    Just adjust your script accordingly.


    The adventure of a life time.

    Linux User #296285
    Get Counted

  6. #5
    Thanks Lazydog, all my other machines are client machines and they mount the home directory of the server. I only have the one server in my network and want to shutdown all the other clients from there. BTW I am using RHEL 5.5

    I did generate the keys in /root/.ssh as and copied it to the folder /etc/ssh of each client machine as I also have two other files there called ssh_host_dsa_key.puband that I did not create. I do not have any output of the key creation process to show but it was successful according to the screen readout. From everything I have read there is supposed to be a file called authorized_keys but it does not exist anywhere on my client machines. Don't know if this is why I still have to enter the password on each machine.

    So I am still at a loss as to why I have to put in the password each time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts