May 04, 2012 - 15:50
It's another Friday Morning at the office, and Sandeep's fingers are running across his keyboard at twice the speed of light (or well, at a few fractions of the speed of light).
Sandeep is the new sysadmin trainee at Zyxware, and he seems tensed and in a hurry.
And there walks in Tingu, all in a jolly good mood, late as usual, humming to herself some silly version of Rebecca Black's Friday Song, adding to Sandeep's morning woes.
Tingu: Hey Sandeep..Goodie Morning!!!
Sandeep: (trying to fake a smile) Morning Tingu..
Tingu: What happened, you look so dumb today morning?
Sandeep: (the fake smile seems to have disappeared from his face) What to do, I wanna go home early today, and the very morning seems to be saying back to me, No You Wont.
Tingu: O no, the day looks as beautiful as any jolly good Friday. What are you upto today?
Sandeep: I got all this SSHing to do on these 14 new servers back and forth, to take some reports, and I'm wasting a major part of my time typing in these SSH commands and passwords.
Tingu: You could use SSH keys to make life easy, cant you?
Sandeep: I too thought of that, but these server owners dont want any keys other than theirs lying on their servers. They want their systems to remain 'untouched'.
Sandeep: (turning towards his monitor) Now that should explain why I look so dumb this morning..
Silence prevails for some time. Everything was back to normal - Sandeep at his keyboard, and Tingu checking through her mails.
All of a sudden,
Tingu: (shouts) Hey Sandeep!
Sandeep: (looking the least interested) What..
Tingu: Tried sshpass??
Sandeep: (curious) What's that?
Tingu: (eyes sparkling) Tan ta taannnnn...
Sandeep: (looking puzzled) ...
Tingu: (turns geeky) sshpass is a small linux shell utility that helps you automate your SSH logins without using SSH keys.
Sandeep: (now looking interested) How? I'm all ears..
Sandeep always knew when Tingu went into geeky mode - she takes the look of a sage whenever she did that. Reminded him of an old roommate he had at his college hostel. He couldnt hide his respect for her whenever she did that.
Tingu: (smiles) Try this at your terminal:
sudo apt-get install sshpass
sshpass -p "password" ssh username@server
Sandeep's fingers ran across his keyboard as soon as she said that. He knew when Tingu meant business, it was for good.
As soon as he typed in the commands and hit the last ENTER, Sandeep’s face lit up like fireworks.
Sandeep: Wow! This thing saves me half the time!
Tingu: (laughs) Wait. You havent seen the best part yet. Now try this:
alias server1=’sshpass -p "password" ssh username@server1’
Then to login to server1, you just have to type “server1” - that’s all!
Do this for the rest of your 14 servers, and your job is all a breeze.
Sandeep: (speechless) Tingu, you saved my day!
Tingu: (laughing) O no, Linux saved your day. Linux Ish Bootiful!
Tingu gets back to her desk, humming Rebecca’s Friday Song. Though his sentiments for the song had not changed a bit, Sandeep is now all happy about Tingu and Linux and sshpass, and doesnt have the time to fight with Tingu over that.
Do check this out and tell Tingu if sshpass saved your day as well.
If you face any difficulty getting sshpass to work for you, just pop in a comment below. Tingu would be happy to help you too. :)