#!/bin/bash
echo "********************************************"
echo "* *"
echo "* change all user ==> A *"
echo "* other user ==> username *"
echo "* *"
echo "********************************************"
read -p "all_user or one_username : " A
if [ $A == "A" ];then
username=$(cat /etc/passwd|grep 'bin/bash'|grep -v root|awk -F ":" '{print $1}')
else
username=$A
fi
function make_passwd {
pw=$(openssl rand -base64 12|egrep -v "0|o|l|I|1"|tr "+|/|'\'" '$')
}
IP=$(ifconfig|sed -n 2p|awk -F " " '{print $2}')
Hostname=$(echo `hostname`_`echo $IP|awk -F "." '{print $3,$4}'`|tr ' ' '_')
for user in $username
do
while true
do
make_passwd
if [ -n "$pw" ];then
echo "$pw" |passwd --stdin $user >> /dev/null 2>&1
echo -e "$Hostname\t$IP\t$user\t$pw"
break
fi
done
done