≡ Menu

Shell Script accept password using read commnad

#!/bin/bash
# Script accept password using read commnad
# Not *very secure*, this script is for learning purpose only
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
PASS="abc123"
read -s -p "Password: " mypassword
echo ""
[ "$mypassword" == "$PASS" ] && echo "Password accepted" || echo "Access denied"

Comments on this entry are closed.

  • Not working for me. Find the outpur below

    bash-3.00$ sh testing_pass.txt
    hi
    hi
    bash-3.00$

  • #!/bin/bash
    PASS=”abc123″

    read -s -p “Password: ” mypassword
    echo Enter Password:

    if [ “$mypassword” = “$PASS” ]
    then echo “Password Accepted”
    else echo “Access Denied”
    fi

  • write a shell script with the following tasks:
    1. login (including your username and password).
    2.add, delete user name and password / add, delete group
    3. firewall.
    Note: as a general file.sh order from 1 to 3

  • ngovuongbinhtay

    help me …
    Write a shell script setup linux security policies include:
    1. password policy
    2. User policy
    3. firewall
    Note: Create a file.sh from 1 to 3. purposes:
    If (1) successful
    then 2
    If (2) successful
    then 3
    End

  • Prakash Rana

    Not working for me.

  • ashwini

    thank u friend