Web Hosting Talk







View Full Version : openvpn remote authentication via bash script


eric6630
09-13-2011, 04:04 AM
hi

im using cent OS 5.6 and im a confused how it's to be done exactly the way i want it to be.

can somebody help me?

thank you

VMStormVPS Dave G
09-14-2011, 09:40 PM
What exactly are you trying to achieve?

Give us a little more info and we can help out.

Best,
Dave

eric6630
09-14-2011, 09:45 PM
#!/bin/bash
### Database Informations
DBUSER='user'
DBPASS='pass'
DBHOST='x.x.x.x'
DBNAME='dbase'

user_name=`head -n1 $1 | tail -1` #first line -> Username
pass_word=`head -n2 $1 | tail -1 ` #second line -> Password

user_query=`mysql -u $DBUSER -p$DBPASS -D $DBNAME -h $DBHOST --skip-column-name -e "SELECT username FROM user WHERE ( (active = '1') AND (username = '$user_name') AND (password = ('$pass_word')) );" $DBNAME`

if [ "$user_query" == "$user_name" ]; then
exit 0
else
exit 1
fi

server connection is good but i guess the problem is on my sqlquery can't retrieve info and compare it from authentication purposes

user_query=`mysql -u $DBUSER -p$DBPASS -D $DBNAME -h $DBHOST --skip-column-name -e "SELECT username FROM user WHERE ( (active = '1') AND (username = '$user_name') AND (password = ('$pass_word')) );" $DBNAME`

can you help me?