How do I copy SSH keys to P1-P4 when using usbboot/rpiboot?
Since the filesystems for P1-P4 are stored on the Controller it's even easier to setup SSH keys to log into the Pi Zeros without using a password from the Controller.
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
mkdir -p /var/lib/clusterctrl/nfs/p{1,2,3,4}/home/pi/.ssh/
cat ~/.ssh/id_rsa.pub >> /var/lib/clusterctrl/nfs/p1/home/pi/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> /var/lib/clusterctrl/nfs/p2/home/pi/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> /var/lib/clusterctrl/nfs/p3/home/pi/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> /var/lib/clusterctrl/nfs/p4/home/pi/.ssh/authorized_keys
You should now be able to log into the Pi Zeros.
ssh pi@p1.local
To run a command on all Pi Zeros sequentially you can reuse a portion of the above command.
for I in 1 2 3 4; do echo -n "p$I:";ssh pi@p$I.local uptime;done
You should see something similar to the output below which shows how long each Pi Zero has been booted, number of users, etc.
p1: 21:43:32 up 24 min, 3 users, load average: 0.01, 0.02, 0.00 p2: 21:43:33 up 6 min, 2 users, load average: 0.07, 0.08, 0.05 p3: 21:43:33 up 5 min, 2 users, load average: 0.00, 0.07, 0.04 p4: 21:43:34 up 4 min, 2 users, load average: 0.02, 0.11, 0.06Tags: cluster hat, clusterctrl, clusterhat, copy, keyless, pi zero, ssh