Showing posts with label Linux two Face ssh authcation with centralize Database server. Show all posts
Showing posts with label Linux two Face ssh authcation with centralize Database server. Show all posts

Sunday, 21 October 2018

Linux two Face ssh authentication with centralized Database server

Create Databases :- 

  1. mysql -uroot -p
  2. create database Login;
  3. use Login;
  4. create table user (id int(10), Name varchar(25), Password varchar(25));
  5. insert into user (id,Name,Password) values (1,'mukesh','mukesh@123');
  6. exit

Copy Below script  :-


vim /tmp/Login.sh




#!/bin/bash
mukesh=`/usr/bin/ps ax | grep $$ | grep -v grep | awk '{ print $2 }'`
user=root                 #Databases UserName
password=Voip@90 #Database Password
DB=Login                 #Database Name
host=192.168.2.176 #Set Local or centralized Server Ip
while [ 1=1 ]
do
UserName=$(whiptail --inputbox "please enter your username" 8 78 --title "User Name" 3>&1 1>&2 2>&3)
                                                                        # A trick to swap stdout and stderr.
# Again, you can pack this inside if, but it seems really long for some 80-col terminal users.
exitstatus=$?
if [ $exitstatus = 0 ]; then

                Password=$(whiptail --passwordbox "please enter your Password" 8 78 --title "Password" 3>&1 1>&2 2>&3)
                if [ $exitstatus = 0 ]; then
        {
    for ((i = 0 ; i <= 100 ; i+=5)); do
        sleep 0.1
        echo $i
    done
} | whiptail --gauge "Please wait while we check..." 6 50 0

                IsUserExist=$(echo "SELECT count(*) as '' from user  WHERE Name='$UserName'  AND Password='$Password' limit 1 " | mysql $DB -u $user -p$password )
                        if [ "$IsUserExist" -eq 1 ] ;then
echo "Thanks for Login $UserName" > test_textbox
#                  filename height width
whiptail --textbox test_textbox 12 80
                        break
                        else
                        echo "You have enter wrong Username & Password." > test_textbox
#                  filename height width
whiptail --textbox test_textbox 12 80
                        logout=`/usr/bin/pkill -9 -t $mukesh`
                        continue
                        fi
                else
                logout=`/usr/bin/pkill -9 -t $mukesh`
                fi

else
    echo "User selected Cancel."
logout=`/usr/bin/pkill -9 -t $mukesh`
fi
done

How To Open A Port In CentOS 7 With Firewalld

Open Specific Port Opening a port in firewalld is fairly straightforward, in the below example we allow traffic in from any source IP ad...