I'm trying to build a raspberry pi cluster with 4 raspberry pis. I'm writing a script to add new users to the system such that the user can be added on all the 4 Pis without having to enter it multiple times. The command I'm using is adduser and I'm adding users on to all the 4 Pis using ssh. This is how that line in the script looks:
echo `ssh pi@10.10.10.13 "sudo adduser --shell /bin/bash user1"`
This is the line I'm using to add a new user. However, the command after this is where I need to change the password. If I use
sudo passwd user1
in the script, for each Pi, it prompts the user for a password 4 times. I don't want this to happen. Is there any way to get the user to enter the password once and store it in a variable and supply this to the passwd command?