While setting up my Raspberry Pi Cluster I needed passwordless SSH access between the master and worker nodes. There are a few ways to do this which I detail below.
ls -l ~/.ssh/id_rsa.pub
Keychain steps below allow for passwordless SSH access from
Keychain is a manager for ssh-agent.
sudo apt-get install keychain
The steps below are based on the work by Ben Heidorn - udemy.com
A common user is needed on each node to allow the nodes to authenticate and execute the MPI commands. I used the username
mpiuser. By default the PI’s install with the user
PI and password
sudo useradd -m -u 2345 mpiuser
-m creates the home directory,
-u is the user id, I think you can use any user id as long as they are same on all nodes.
sudo passwd mpiuser ~ raspberry for both prompts, secure I know!
Now login as user
mpiuser to test it works
su - mpiuser ~ switch to the mpiuser user
Repeat the same for node3, this can be done over SSH using the PI user. You can connect using
ssh pi@node3. When done run
exit to fall back to node1.
Allow each node to authenticate using SSH (Secure Shell) using public & private keys.
su - mpiuser
-t rsa is the encription type
ssh-copy-id mpiuser@node3 ~ copys the ssh key to node3 (this would need to be done for nodes2/4)
To allow the user to login without a password/passphrase. This is done on the Node1 (master)
At the bottom of the file add
# keychain magic
After saving the file recompile it by running
Now you should be able to run
ssh node3 and not be asked for a password.
ssh-keygen -t rsa ~ default location `/home/pi/.ssh/id_rsa`
ssh-keygen -t rsa
This will copy the keys to