Created
May 15, 2014 03:48
-
-
Save bzz/b5d62bf3e1c08dca683d to your computer and use it in GitHub Desktop.
Create a new user on a multiple linux machines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Creates new user with given passwd on the set of machines | |
hosts="$@" | |
total_created=0 | |
for host in ${hosts}; do | |
ssh -t root@"${host}" <<'ENDSSH' | |
useradd PLACE-USER-HERE -p PLACE-ENCRIPTED-PASSWORD-HERE(i.e from /etc/shadow) | |
ENDSSH | |
if [[ "$?" -ne 0 ]]; then | |
echo "Unable to create new user on ${host}" >&2 | |
else | |
((total_created++)) | |
fi | |
done | |
echo "${total_created} users ceated" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment