Saturday, December 17, 2011

Twitter for System Administration

How about shutting down/restarting your system via SMS? 
Is that something that is possible? Yes , With twitter SMS service that is of course possible. This can come handy for system administrators. Here I will show you how to control your system  on the move via SMS, using the services provided by the twitter.
          Initially we will create two twitter accounts , call them Master and Slave. Master account will be a normal account, on the other hand Slave will be a private account, which has connection only with Master(i.e Slave will be only following the Master and the only follower that Slave has, will be Master). This helps preventing users other than Master sending messages to the Slave.
           The next step will be a program that monitors the message inbox of the Slave for the messages from the Master. This program have to be run on the system that has to be controlled. The program should be able to log in to the account of Slave and to check out its inbox. That's where twitter API comes to rescue. For various reasons twitter prevents earlier Basic authentication. So we have to rely on OAuth . OAuth is a trickier authentication method , whose explanation is beyond the scope of this article. Using twitter api resources we will be checking out the message inbox of Slave. Remember Master is the only user in twitter who can send messages to the Slave . Also message to a twitter user can be sent via SMS .Messages are monitored by the program and depending on the message, necessary actions are taken. Below is simple program that will Shut down/restart the system depending on the message. 

Though the sample program can only be used for Shutting down/restarting the system ,System Administrators can add the functionality like auto replying to the queries issued by the Master, thus achieving a greater control over the system via SMS.
Note : Python tweepy module is a module that helps in communication with twitter. It can be installed in linux system by the command easy_install tweepy. Also the program is installed in crontab ,so that it runs every minute.


  1. To me this seems like such a bad idea. Perhaps I just doubt the security of Twitter (which I do). This is a solution in search of a problem. The big issue I have is that there is a much simpler, much more reliable, (and more secure) solution to the problem solved by this service...

    When I got my phone, I made sure it had a good SSH client. (A "Good SSH client" on a phone supports public key authentication, authentication forwarding, and has a functional 256-color Terminfo entry.) When I want to do Sysadmin stuff on my phone, I do the same stuff I do on a desktop: I SSH in to the box and administer it. Also, perhaps the system has suffered a major issue and I fear it has kernel panicked and I need to connect to the serial console -- that's easy too (at least for the systems not virtualized -- *grumble* VMware). (This also means I can have a headless machine, and confirm it is safe to unplug while in the machine room without a crash cart.)

    There's a great SSH client for Android. All it took on my part was making sure I had a physical keyboard so I'd have a normal amount of screen space. (I get better than 80x25 -- not much better if I want to read it -- but 80x25 is enough for all full screen terminal applications to work properly.)

    Why use a hard-to-implement half-assed solution when your phone supports the same solution you use on the Desktop?

    (Besides, the benefit of using SSH is that you can play a Roguelike on it, too. You can't do that over Twitter.)