Configuration of a Linux Cluster using SSH

Tyler Simon

Step 1: Create a new user

As root create a user that will be using the cluster. In this case our user is robert.

After creating the user we need to create a home directory for them and give them a password, and then set the permissions on their home directory.

#>useradd robert

#>mkdir /home/robert

#>passwd robert

#>chown robert:users /home/robert

Step 2: Generate and Distribute Public and Private Keys

now login as the user 'robert'

#> su - robert

As the user 'robert' execute the following to generate a private key and public key.

$>sshkey-gen -t dsa

When prompted for a passphrase there is no need to enter one, just press enter to continue. The user's keys will be stored in the /home/.ssh/ directory. Execute the following steps in succession for each machine on the cluster. Note that in step one we create a file called authorized_keys and in step 2 we append to this file from other machines.

  1. Copy the file into the $HOME/.ssh directory to another machine on the cluster (node2 node3...) and name it 'authorized_keys'. Below is an example of copying the file to node2.

NOTE: Each new public key generated by a node on the cluster must append the authorized key file, if the file already exists!

$>scp ~/.ssh/ \ node2:/home/robert/.ssh/authorized_keys

  1. To append to the ~/.ssh/authorized_keys file execute the following from the host where the public key was generated. Essentially you are copying the public key to the other computer with a temporary name that we will use to append to the authorized_key file.

    $>scp ~/.ssh/ \ node2:/home/robert/.ssh/receivedkey

    Now ssh into the machine where you have just copied the file, in the above case this would be node 2. Then append the file.

    $>ssh node2

    NOTE: If node2 cannot be found, modify the /etc/hosts file to include the hostname and ipaddress.

$> cat ~/.ssh/receivedkey >> ~/.ssh/authorized_keys

The current configuration should include the following. Each machine that generated public and private keys should have sent their public keys to all machines in the cluster, with each public key being contained in the file “authorized_keys” on each node.

You should now be able to ssh to any node, and not be prompted for a password.

Step3: MPIch Installation

Download the most recent version of mpich here:

download the UNIX (all flavors) tar.gz file and save it into robert's home directory and unpack the file. From the mpich directory execute ./configure and then make. Modify the ~/mpich/util/machines/machines.LINUX file to contain

$> cat mpich.tar.gz | zcat | tar xvf -

$> cd mpich-1.2.6



$>vi util/machines/machines.LINUX

Make sure your machines.LINUX file contains the following





change your directory to the $MPIHOME/examples/basic and make the programs and execute using mpirun in the bin directory

$>cd /home/robert/mpich-1.2.6/examples/basic/

$>make all

$> ../../bin/mpirun – np 3 cpilog

Now we are done, please contact me if you have any problems.