Installing and configuring SSH

In this section, we will look at the steps to install and enable a passwordless SSH. It's always better that you have a dedicated Linux user for Hadoop and HBase processes. Let's create a user for Hadoop and HBase and name it hbasehadoop. We will use this user to start and stop all Hadoop/HBase daemon processes. Once the user is created, we can generate SSH for the same and set up a passwordless SSH on all machines. This user must exist on all machines in the cluster. Also, this user must be provided a root access if we need to install SSH using this user, else we can create a simple user just to start and stop the process, and we can install using the existing root user. The following figure will give you a clear picture:

Installing and configuring SSH

To add a user, the current user must be a root user. So, switch to the root user using the following command before setting up a password:

useraddhbasehadoop

To set a password for the hbasehadoop user, use the following command:

passwdhbasehadoop

From now on, we can use this user to start, stop, and configure Hadoop/HBase.

Installing SSH on Ubuntu/Red Hat/CentOS

Install SSH if it's not installed already. Use the following commands for this:

sudo apt-get install openssh-server

The preceding command will install an SSH server.

sudo apt-get install openssh-client

The preceding command will install an SSH client.

Once this installation successfully finishes, we can start configuring SSH.

Configuring SSH

Follow these steps to configure SSH:

  1. The following command will generate a key-pair file in the current user's .ssh folder, which is in the home folder for the user. Just press Ctrl + H to show hidden files:
    ssh-keygen -t rsa -P ""
    
  2. After issuing this command, just keep pressing Enter; don't enter the filename or anything else. It will show the following output:
    Generating public/private rsa key pair.
    
  3. Next, the Linux terminal will ask you to enter the file in which to save the key; just press Enter.
  4. After this, you will get the shell prompt back. Type in the following command:
    cat $HOME/.ssh/id_rsa.pub>> $HOME/.ssh/authorized_keys
    

    This will create authorized_keys in the .ssh folder and put your public key in it so that you just need to type in sshlocalhost the next time, and it will log in to localhost without asking for the password.

  5. Change the permission of the .ssh directory to 600 for security. This directory will be found in the home directory of the user for which key has been generated.
  6. Once a public/private key pair is generated, we need to copy and paste this public key to the authorized_keys file on the machine, which we need to log in to or start/stop the process without a password.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.168.8