Skip to content

Instantly share code, notes, and snippets.

@hupili
Created December 1, 2014 09:22
Show Gist options
  • Save hupili/681492719f9ae78c4e78 to your computer and use it in GitHub Desktop.
Save hupili/681492719f9ae78c4e78 to your computer and use it in GitHub Desktop.
Programmably regenerate passwords for users (Ubuntu)
#!/bin/bash
# Usage: put list of users in "users" file.
# one user per line.
# Passwords will be changed and stored in "passwd.list"
rm -f passwd.list
for user in `cat users`
do
password=`echo "sdf982ci237986ahah:$user" | sha1sum | cut -c1-16`
echo $user
echo $password
echo "$user:$password" | chpasswd
echo "Linux changed"
echo -e "$password\n$password" | smbpasswd -a -s $user
echo "Samba changed"
echo "$user $password" >> passwd.list
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment