Tagged: innovation Toggle Comment Threads | Keyboard Shortcuts

  • Kartik 8:40 AM on February 12, 2012 Permalink | Reply
    Tags: , , , , , innovation, , , , , ,   

    Control All Computers in a Lab from a Single System 

    Quoting Dhandeep, our super-cool lab-admin:

    now , all 70 systems in the lab can be switched on and switched off by single commands from the hostel…

    Yes, that and a lot more is possible in our Software Systems Lab now. How? Read on…

    The Setup

    We have over 70 systems with Ubuntu 10.04 LTS installed on them. There is an administrative account (let’s call it admin for this post) and a guest (limited privilege) account on each. Needless to say, admin password is known only to admins and guest password is known to all who use the lab. All these systems are configured to be able to controlled remotely (read: OpenSSH server is installed on each).

    Basic Idea

    1. Log in via SSH without a password
    2. Write your desired command and run it in background
    3. Run the above in a loop for the lab’s subnet.

    Detailed Steps

    See Tips for Remote Unix Work (SSH, screen, and VNC) for the first step (and for more immensely useful tips on remote usage of *NIX systems).

    For Step 2, here is one example command:

    ssh -t admin@labsystem "echo  | sudo -S shutdown -h now" &

    In the above command labsystem is usually replaced with an IP address like 192.168.xxx.xxx and the <pass> with the password of the admin account.

    WARNING: it’s not suggested to use the above command out in the open to save the password from prying eyes; also note that for additional security, you need to take a measure to make sure this is not saved in bash history or if the command is in a script, it’s not accessible to others.

    The requirement of ampersand at the end depends on particular usage (if you want to run, let’s say,  uptime command over ssh, you would not want the output to go to background, or you can redirect the output to some file). Putting the process in background, in this case, will help in the next step.

    The -S switch for sudo makes it possible to supply the password via stdin (we had discovered this switch from sudo’s man page, but didn’t manage to conclude “echo pass |” will do the trick until we discovered it at StackOverflow)

    Step 3: use your favorite scripting language (bash, python, etc.) and run the above command for all the systems of your lab subnet. An example in bash:

    for ip in {101..180}
    do
    	ssh -t admin@192.168.xxx.$ip "echo  | sudo -S shutdown -h now" &
    done
    

    The above code snippet will run the desired command for all systems in subnet within the IP range 192.168.xxx.101 to 192.168.xxx.180. Now, you can clearly see how putting the process in the background will help – the next iteration of the loop need not wait for the command in previous iteration to finish!

    In the passing, here’s a small video I shot featuring Dhandeep when he got all excited to see this working:

    That’s it. Try this out, share your tricks and have some *NIX fun in your lab. :-)

    PS: I have not covered how systems can be switched on with this setup. It basically involves broadcasting a magic packet to the subnet. Hope Dhandeep comes up with a blog post on that soon. ;-) Here it is: On the push of a button..

    Ciao

    Kartik

     
    • firesofmay 8:53 AM on February 12, 2012 Permalink | Reply

      Sweet! I love it! ;)

    • Amarnath 8:54 AM on February 12, 2012 Permalink | Reply

      Interesting. But, I think you forgot to mention the important prerequisite for doing this task. Don’t you need to generate public keys for all machines to be controlled and pass it to the central control node? I believe only this would help in password-less remote login via SSH.

      Indeed Dhandeep seems to be pretty excited about it. :-)

      Cheers

      Amarnath

      • Kartik 10:03 AM on February 12, 2012 Permalink | Reply

        Thanks for your comment Amarnath.

        Indeed, that is necessary and is mentioned as the first step. But instead of describing the whole process myself I chose to point to a good resource (Tips for Remote UNIX Work…) for that kind of setup. You missed out perhaps. ;-)

    • Lokesh Walase 5:41 PM on February 12, 2012 Permalink | Reply

      Awesome !! :)

    • Imran 11:04 PM on February 13, 2012 Permalink | Reply

      You can use puppet to design more efficient system which gives you more flexibility in automation

      • Kartik 12:56 AM on February 14, 2012 Permalink | Reply

        Yeah, that’s right. I have that in my to do list to learn soon. :-) Though, I am not aware if it works for normal desktop systems too.

  • Kartik 8:38 PM on May 30, 2011 Permalink | Reply
    Tags: , innovation,   

    The Great Indian Jugaad 

    image

    Just spotted this unique and innovative use of cheap UPS batteries in the local vegetable market (sabzi mandi) near my home at Ghaziabad. I could see dozens of these lamps in a row in the market. At a place like ours with such severe power cuts, this seems like a good alternative for the vegetable vendors.

     
    • Abhimanyu 9:46 PM on May 30, 2011 Permalink | Reply

      Have seen this it is not just about Power Cuts… The thing is it is highly portable, and more over they don’t need an permanent electrical connection and the hassles associated with obtaining one and maintaining it.

      • Kartik 9:52 PM on May 30, 2011 Permalink | Reply

        They actually had power connections, but no other option when there are cuts in the evening. As I write this power just came back after about 4 hours.

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
Follow

Get every new post delivered to your Inbox.

Join 55 other followers