In case you're attending a Raspberry-Pi based Akka Cluster workshop
, you will need to prepare your laptop to integrate with a pre-installed 5-node cluster you'll be working on.
The following sections give instructions on how to achieve this.
On your Mac, add the following entries to your /etc/hosts file:
# Cluster #0
192.168.200.10 node-0
192.168.200.11 node-1
192.168.200.12 node-2
192.168.200.13 node-3
192.168.200.14 node-4
Next, we set-up password-less login (unless your ssh
remembers your password, in which case you can skip this step). We assume that we want to log in to account akkapi on a Raspberry Pi node from an account (userxxx) on your laptop. In order to set-up password-less login, you need a so-called public/private key pair. If you're unfamiliar with this concept, or don't have such a key pair, first read the paragraph titled Generating a public/private key pair in the Addendum.
Now, proceed by executing the following command on your laptop:
Pi-Akka-Cluster git:(master) ✗ for node in 0 1 2 3 4;do ssh-copy-id akkapi@node-${node}; done
For each of the 5 nodes, you will be prompted to confirm that you want to connect (enter yes
) and the password for the akkapi
account which is akkapi
.
With this, you should now be able to log into the akkapi account on all nodes from the userxxx account on your laptop without having to enter a password.
Finish the configuration by running the updateScripts
command:
Pi-Akka-Cluster git:(master) ✗ ./updatePiScripts
Copy to node-0
run 100% 1104 450.3KB/s 00:00
librpi_ws281x.so 100% 92KB 6.4MB/s 00:00
setLedType 100% 110 32.1KB/s 00:00
docker-compose.yml 100% 1136 76.1KB/s 00:00
runDocker 100% 98 61.0KB/s 00:00
Copy to node-1
.
.
.
We assume that we want to log in to account akkapi on a pi from an account (userxxx) on your laptop.
First, we need a pair of authentication keys on the laptop. If these keys have been generated already we can skip the generation of a new pair of authentication keys. If this isn't the case, generate them.
Logged-in on your laptop account, generate a key pair:
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/userxxx/.ssh/id_rsa):
Created directory '/home/userxxx/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/userxxx/.ssh/id_rsa.
Your public key has been saved in /home/userxxx/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 userxxx@A
Use an empty passphrase (just hit Enter)
As can be seen from the output generated by ssh-keygen, a pair of files (id_rsa
and id_rsa.pub
) are created in the (hidden) folder .ssh
in the users home folder.
Let's have a look:
$ ls -l ~/.ssh
total 56
-rw------- 1 ericloots staff 3326 Dec 21 2015 id_rsa
-rw-r--r-- 1 ericloots staff 746 Dec 21 2015 id_rsa.pub
Additionally you can apply host specific options in ~/.ssh/config
, which is the client-side configuration file located in the user's home directory. This file is not created by default. It is safe to create it now with the below command. Altenatively use a text editor to add the node-*
(wildcarded) Host
section (only the 5 indented lines).
This way you can define custom connection options, and change the username, keyfile or setup more permissive host key checking.
$ cat <<HERE >> ~/.ssh/config
Host node-*
User akkapi
IdentityFile /Users/userxxx/.ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
HERE
$
Essentialy SSH checks for each defintion, and if it matches the hostname value given on the command line, it applies the configurations found in the matching section.
Let's try the login with SSH client-side configurations:
$ ssh node-0
Linux node-0 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l
HypriotOS/armv7: akkapi@node-0 in ~
$