Thursday, 13 September 2012

SSH connection to Remote machine with out password


Fig ( A )






I was able to setup 2 node Hadoop clusters as shown above (i.e. Ubuntu1 & Ubuntu2)
When I started Hadoop in master node as “start-all.sh”
It is not generating any file in Hadoop folder of slave (Ubuntu2), instead it was giving error
After analysing and doing Google I figure out,It is not getting connected using SSH to Ubuntu2

Problem Identification


When try to connect using SSH from Ubuntu2 to Ubuntu1 it gives error as shown



Actual method to SSH connection without password

Copy public key of Ubuntu1 to authorised_key of Ubuntu2 and
Copy public key of Ubuntu2 to authorised_key of Ubuntu1
Already above work was done still I was having the issue mentioned

Reason

When we try to connect from Ubuntu1 to ubuntu2 using SSH ,
It will look for same username in Ubuntu2 computer
i.e if Ubuntu1 is having username as APPLE when connecting to Ubuntu2 it will use default username as APPLE
In my case Ubuntu1 username is master and Ubuntu2 user name is slave hence it is not working

Solution

Created a new User in Ubuntu2 as master and given all permissions of old user (ie slave)
See below for new setup
Fig ( B ) 





If you see the difference in figure  A and B
the UserName in Fig (B) are same in Ubuntu1 and Ubuntu2
  
Now I when I connect ssh with hostname it is successful


Also when I start hadoop in master node it started TaskTracker and DataNode in slvnode

NOTE: In case of having different username if we still want to connect we can use as <username@<hostname>
ie ($ ssh slave@slvnode)