Managing many FreeBSD and Linux servers is easier when all machines use the same user account. In this guide, you create one user, generate one password hash, and add the same user to all servers with a simple Bash script. This method works on FreeBSD and Linux systems.
Here are 5 steps to do that.
1. Generate the password hash
FreeBSD uses SHA‑512 for password hashing. You can create the hash on any machine that has OpenSSL installed.
root@OF:~ # openssl passwd -6 "YourPassword123" $6$kePS2TPyaJzqukP5$D.5y.PQBm84E27t1dP6AOCrSVJ.O9/u.mfebZRh04DBLG6Sc7.63.Cb51VSZ0Fe3xI3B80KHLlXoBMZ6.eHEY0 root@OF:~ #
This is the hash you will send to each FreeBSD server. The real password stays local.
2. Create a host list
Make a file named hosts.txt with one server per line.
freebsd1.example.com freebsd2.example.com 192.168.1.10 192.168.1.11
SSH access must already work (password or SSH key).
3. Bash script to add the same user to all FreeBSD servers
#!/bin/bash
USER="newuser"
PASS="YourPassword123"
HOSTFILE="hosts.txt"
# generate SHA-512 hash
HASH=$(openssl passwd -6 "$PASS")
while read -r HOST; do
echo ">>> $HOST"
# FreeBSD user creation with hash from stdin
ssh "$HOST" "sudo pw useradd $USER -m -H 0" <<< "$HASH" \
&& echo "OK" \
|| echo "User exists or error"
done < "$HOSTFILE"
How it works:
pw useraddis the FreeBSD user management tool-mcreates the home directory-H 0tells FreeBSD to read the password hash from standard input- The hash never appears in the command line on the remote machine
4. Add the user to the wheel group (optional)
If the user needs sudo access:
ssh "$HOST" "sudo pw usermod $USER -G wheel"
5. Verify the user
On any server:
id newuser grep newuser /etc/master.passwd
If you see $6$ in the password field, the hash is correct.
Summary
- You generate one SHA‑512 hash locally.
- You store all server names in
hosts.txt. - You run one Bash script.
- All FreeBSD machines get the same user with the same password.
- The method is clean, simple, and safe for multi‑server environments.