Friday, November 21, 2014

Create a passwordless SSH login to remote computers to automate launch of a zookeeper cluster

Passwordless SSH Login can be useful in situations, for example, when one likes to write a bash script that automatically setup or launch a zookeeper cluster. Suppose we want to ssh login to a computer at without a password from a our client computer at, we can do so by creating a RSA pair of authentication key at terminal:

> ssh-keygen -t rsa

In the terminal prompt, just press the ENTER key multiple times for each prompt. Once this is done, a public key is stored in the .ssh folder under the user root folder. Now ssh login to the (password required at this point) to create the .ssh folder under the user root folder on that computer:

> ssh username@ mkdir .ssh

The last step is to append the .ssh/ file (which is the public key) from to the .ssh/authorized_keys in (password required at this point):

> cat .ssh/ | ssh username@ 'cat >> .ssh/authorized_keys'

Now we can ssh login to from the client without password. For example, run the following command in the client terminal:

> ssh username@

Now we are ready to write a bash script to launch the zookeeper cluster which consists of the following networked computers:

First make sure that the zookeeper is setup in the cluster properly (follow instructions from this link: and for storm at this link and make sure the above steps of passwordless SSH login is repeated for and so that user can log into these two computers without password from the client Now on the terminal of, create a script:

> touch
> gedit

In the that opens, enter the following lines:

ssh username@ $ZK_HOME/bin/ start
ssh username@ $ZK_HOME/bin/ start
ssh username@ $ZK_HOME/bin/ start

Save and close the, and run the following command on client terminal to make it executable:

> chmod +x ./

Now run the script to start the zookeeper cluster:

> ./

We can also write a,, in a similar way to automate the process.