Saturday, June 26, 2010

A script to do ssh easily

This is something which reduce my job a lot while working in my Linux box. While in work i have to connect to a lot of PC vi a ssh [secure shell]. And everytime i have to type"ssh root@172.xx.yy.zz " and then wait for the password prompt and then type the password. Ans sometimes it may not be root it might be some other user name but unnecessarily i need to repeat typing this "@172.xx" as this part is always common in a company. And most of the time I log in as root so i could avoid "root@172.xx." that saves a lot of energy; it seems 217 microjoules per keystroke; so its 217*11 mirojoules saving. So lets see the script which saves this energy.

if [ $#  -eq 0 ] //Check whether u have given any argument
echo "Input the lan ip for ssh"
elif [ $# -eq 1 ]    //check if argument is equal to one  [means default is root connecting]
echo "Connecting to 172.22.$1 as root"
ssh root@172.22.$1 -X
else "Connecting to 172.22.$1 as $2"  //take the second argument which is the username.
ssh $2@172.22.$1 -X

1)Name the file as c then [c for connect]
2)Store this file under /usr/bin may be with a name C. [so that u can access this like command]
3)Run the command
4)chmod 711 [group and others will get only execute access]

So now i have to type to connect ssh
c yy.zz   [to connect ssh root@172.xx.yy.zz]
c yy.zz username [to connect ssh username@172.22.xx.yy.zz]

This code if provided with 2nd argument which is considered as username then it will connect to that username else it will connect to root.

So in this way i make my work easier.

Find invisible users of Gtalk / Gmail

Latest Update :14th November 2010
If you are visiting the site first time please visit these links:
link1 [about old release] and link2 [about new release]
If you have come here to find new release make sure you read completely of this link:
link1 [about new release]
If you want to know history of finding invisible user from this site, visit these:
link1 link2 link3 link4

About old release:
The invisible part of this software has stopped working from 8th October 2010. Google talk has changed its presence notification in a different way.Click here. Finding blocking users is still working in this software, use it before the google do a patch for that too.

I thought of making this code after getting inspired by the code written by Srijith. He has written a perl script using some perl packages to find the invisible users of gmail. His blog has well explained the working of the code from a layman point of view and from a coder too. So i am not going to explain the things which he has written, please visit his blog for that explanation he has written it very well in the first a few paragraphs [let him get some more visitors in his site].

I thought of making using the concept explained by Srijith in Java. So after a bit of google i came across the package Smack. It completely defines the gtalk functionality. I have used only some of its method defined for finding presence. And with netbeans i created the GUI using Java swing.

1)Easy to you. Small size.Free to use.
2)You keep yourself in Invisible mode while finding other invisible users.
3)Can be used with Google Apps Google talk.[other than]
4)Source of the available users can be seen.
5)Works in Linux, Mac,Solaris,Windows.[as its developed in java]

Before downloading people like to see what it is. So here is the screenshot of the Program.

Read Carefully:

1) Unavailable users are those users who are logged in Gmail and have gone in invisible mode. Unavailable users also include some of the users who are logged in Gmail or igoogle or any other mail checking client and have logged out from the gtalk. [Well once you have logged out from Gtalk you should not be seen but still i am finding that though they are logged out they come and check the presence of available users; might be a bug in Gtalk; hence i cannot rectify this bug].

2) Available users are those users who are logged in and available to talk. You may find these users login source that is they are logged in from gmail,orkut, Talk[Google Talk] or any other with an id number after it.Something like this gmail231231,orkut2342423,TalkD342343,etc. The point to note is if your buddy has opened many gmail window then you will find all his resource with different id number. Well i did not remove this part as some times its quite useful.

As such the invisible users source you will not find but sometime a rare case happen. Your buddy might have kept in Gmail as invisible mode and would have logged in Orkut by keeping available; hence at that time you will find your buddy's source of login even in the unavailable users list.

3) Domain is a very important part but do not edit it if you don't know. Normally and most of the time it is Sometimes may be your company or your university or school might be hosting their email with the gmail [in short i am talking about Google Apps] and then might be using Gtalk for chatting; for those users can change it to to their company domain.

Download Now [hope you read the "Read Carefully" instructions].
A newer version of this software Udghosh is available for finding invisible and blocking users on google talk /gmail /orkut . Before using make sure you have completely read about that on that page.
The old version you can download from below links. Old version doesn't work anymore, it has been kept to download only for developers.
File in .zip format. ZipSize:750-760KB. Actual FileSize:853KB. Hosted at

You need internet connection which allows Google talk to login.
You need Java runtime [jre version 1.5] at least.
Check here what version you have
If you don't have any or at least 1.5 download the latest from here 

My support here will be quite low as i am not a frequent blogger. But still will be visiting here frequently, depends upon the comments which i receive here.

So i would like you visit this site as it has clearly explained how to run a Java jar file

But to summarize: 
For All OS: Type in terminal or command prompt "java -jar GtalkInvi.jar " obviously the file should be present in the folder from where the command prompt is started.This works only if environment path of the command/terminal is set properly.
In Windows: Try first double click on the icon if not you need to visit the site wikihow mentioned above.
In Linux: In the terminal try "java -version" if its less than 1.5 you need to download the latest JRE from the site mentioned above and then configure your environment and still not getting check out the wikihow.[And if still not working then i would like to say you need to try hard; there are no more ways. And may be you can do a google "How to run java jar in Ubuntu" change ubuntu to redhat or fedora or suse or which ever linux flavour you are using.
In Mac: Its the easiest way to run. Double click the file. If not working do a software update for java. If still not working; contact Apple customer care.
In Solaris:Almost same like linux, for more instruction visit this site.

Ways to find the invisible users:
1) Srijith blog explains in Perl script
2) Fedrico Sanco explain here. He does this using Pidgin and he made a plugin to do the same. Logic is same; he likes to call as half invisibility for the reason which i explained above. He did in C language.
3) :) My code.
If anywhere else you have seen such a program let me know.

Please put your comment if you are able to make use of this program and find your business friends hiding, unpaid insurance guy hiding, traveling colleague checking the mail, girl friend hiding or any other liers; let me know how you made use of it ;).