Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Bash script to authenticate machine users

echo
echo '============== User Authenticator =============='
echo

if [[ -z $1 ]]; then
        echo "ERROR: enter username like: './script foo'"
        echo

elif [[ -n $1 ]]; then
echo

echo -e "Enter file name: c"
read -r Uname
echo "Results location: '~/$Uname'"

touch ~/$Uname

Uresult=`cat /etc/passwd | grep $1`
IFS=:

set $Uresult
echo "Username: $1" | tee -a ~/$Uname
echo "Pass: $(sudo cat /etc/shadow | grep $1 | awk -F: '{print $2}')" | tee -a ~/$Uname
echo "UID: $3" | tee -a ~/$Uname
echo "GID: $4" | tee -a ~/$Uname
echo "Directory: $6" | tee -a ~/$Uname
echo "Shell: $7" | tee -a ~/$Uname
echo >> ~/$Uname
echo

fi
 
PREVIOUS NEXT
Tagged: #Bash #script #authenticate #machine #users
ADD COMMENT
Topic
Name
2+1 =