Shell changes password randomly and regularly_ passwd.sh

Time:2020-9-30

change_passwd.sh


#!/bin/sh
/usr/bin/chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadow
/usr/bin/echo `/usr/bin/date +%Y%m%d%w` |/usr/bin/awk -F '' '{print $1$5$9"Jack_Cui"$3$5$7}' |/usr/bin/passwd --stdin root
/usr/bin/chattr +i /etc/passwd /etc/shadow /etc/group /etc/gshadow

Crontab – e


#change_passwd
0 10 10,25 * * /bin/sh /srv/change_passwd.sh >/dev/null 2>&1

PS: let’s look at the shell randomly changing the password


#!/bin/bash

name=hostname
ETH1=""
if ifconfig eth1 &> /dev/null;then
ETH1=$(ip a | grep -A 0 "eth1" | awk -F "[ /]" '/inet/ {print $3}')
fi
ETH0=$(ip a | grep -A 0 "eth0" | awk -F "[ /]" '/inet/ {print $3}')

MATRIX1="0123456789"
MATRIX2="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MATRIX3="abcdefghijklmnopqrstuvwxyz"
MATRIX4="./*&^%$#@!()"

LENGTH="16"

ii=1
while [ "${n:=1}" -le "$LENGTH" ]; do
MATRIX=eval echo "$"MATRIX${ii}
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
let n+=1
ii=expr $ii + 1
if [ $ii -eq 5 ];then
ii=1
fi
done
echo "$PASS" | passwd root --stdin
echo "$ETH1 $ETH0 $name root $PASS" >> /tmp/pass.txt
cat /tmp/pass.txt
rm -rf /tmp/pass.txt 
rm -rf /root/test.sh

summary

The above is a brief introduction to shell random timing change password_ passwd.sh Hope to help you!

Recommended Today

Use this code generator developed with electron to boost your code efficiency

EasyCode-JavaScript Using objects Crud too many management page projects, EASYCODE with nodejs access to the database ability, one click to let you generate code use download GitHub download and use https://github.com/chendonmin… Compiling and running clone git clone [email protected]:chendonming/easycode-javascript.git Installation dependency yarn Compile runWithout XXX, this step is very difficult to succeed yarn electron-build start Connect […]