Today I Learned

ins8s

Creating SSH Shared Keys for Cluster Users

Set up SSH shared keys for all of the compute nodes. To create a public and private key, do the following:

  1. Run the following on the head node:

    > ssh-keygen -t rsa
  2. Accept default settings and do not submit a passphrase (press Enter 3 times).

  3. From the head node, SSH onto each and every node in the cluster by hostname (including the head node) to append the host’s public key to the .ssh/known_hosts file.

    > for i in node01 node02 node03; do ssh -o StrictHostKeyChecking=no ${i} hostname; done
  4. Append the contents of id_rsa.pub to the authorized_keys file.

    > cat .ssh/id_rsa.pub >> .ssh/authorized_keys
  5. Create the .ssh directory on all compute nodes in case it does not exist.

    > for i in node04 node05 node06; do ssh ${i} mkdir .ssh; done
  6. Copy the .ssh folder to the nodes.

    > for i in node01 node02 node03; do scp -r .ssh/id_rsa.pub ${i}:~/.ssh; done
  7. (Optional) To allow users access the compute nodes from the head node, copy the authorized keys to the nodes.

    > for i in node01 node02 node03; do scp -r .ssh/authorized_keys ${i}:~/.ssh; done