Skip to content

Instantly share code, notes, and snippets.

@miticojo
Last active June 22, 2016 22:15
Show Gist options
  • Save miticojo/1a5a6ca1990e4be54f244deee683f7ab to your computer and use it in GitHub Desktop.
Save miticojo/1a5a6ca1990e4be54f244deee683f7ab to your computer and use it in GitHub Desktop.
change all user password with a random 8 chars string and print in csv format
#!/bin/bash
random-string()
{
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
for u in $(ipa user-find --sizelimit 200 --pkey-only "." | grep ":" | awk '{print $3}'); do
psw=$(random-string 8)
echo $psw | ipa user-mod $u --password > /dev/null 2>&1
[ "$?" == "0" ] && echo "$u,$psw"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment