Skip to content

Instantly share code, notes, and snippets.

@ion1
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save ion1/69e11c87e0add48237c9 to your computer and use it in GitHub Desktop.

Select an option

Save ion1/69e11c87e0add48237c9 to your computer and use it in GitHub Desktop.
passwd-reset
#!/bin/sh
set -eu
umask 077
for username; do
password="$(pwgen -n 16 1)"
printf '%s:%s\n' "$username" "$password" | chpasswd
chage -E "$(( ($(date '+%s') / 86400) + 2 ))" "$username"
passwd -e "$username"
printf '%s:%s\n' "$username" "$password"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment