batch change all user passwords linux console
Tum kullanicilarin parolalarini toplu halde degistirmek icin hos bir script.
Isim acele oldugundan scripti duzenlemeye vakit ayiramadim oldugu gibi kullandim.
mesela uid i 1000 ve yuksek olanlari listelemesi gereken awk satiri calismiyor adam gibi.
vaktim olunca bakarim bir ara 🙂
orjinal scriptin random password generatoru baska birseyler istediginden onu degistirdim vs vs..
#!/bin/bash
# Script to update user password in batch mode
# You must be a root user to use this script
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# /root is good place to store clear text password
FILE="/root/batch.passwd"
# get all non-root user account
# By default on most linux non-root uid starts
# from 1000
USERS=$(awk -F: ‘{ if ( $1 >1000 ) print $1}’ /etc/passwd)
# create file with random password
echo “Generating file, please wait…”
# overwrite file
>$FILE
for u in $USERS
do
p=$(dd if=/dev/urandom count=200 bs=1 2>/dev/null|tr “\n” ” “|sed ‘s/[^a-zA-Z0-9]//g’|cut -c-8) # create random password
echo “$u:$p” >> $FILE # save USERNAME:PASSWORD pair
done
echo “”
echo “Random password and username list stored in $FILE file”
echo “Review $FILE file, once satisfied execute command: ”
echo “chpasswd < $FILE”
# Uncomment following line if you want immediately update all users password,
# be careful with this option, it is recommended that you review $FILE first
# chpasswd < $FILE
sonra
batch.passwd dosyasini uid 1000 den asagi kullanicilari temizlemek icin editle.
sonra ver gazi.
chpasswd < batch.passwd
oldu bitti.