Openvpn authentication with user name and password

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Goto page 1, 2  Next
Author Message
300000
DD-WRT Novice


Joined: 18 Aug 2011
Posts: 20

PostPosted: Thu Dec 09, 2021 15:16    Post subject: Openvpn authentication with user name and password Reply with quote
I would like to share config so we can use openvpn server with usename and password , just do as follow .


go to Administrator and Command and paste this script and save it as Save start up



echo '#!/bin/sh
pass=`awk "\\\$1 == \"${username}\" { print substr(\\\$0,length(\\\$1)+2) }" /tmp/openvpn-auth`
test -n "$pass" && test "$pass" == "${password}" && exit 0
exit 1' > /tmp/quickAuth.sh
chmod 755 /tmp/quickAuth.sh

echo '
jonh 2qwerty
tony oioou5
kent 8ui-uyu

<etc>
' > /tmp/openvpn-auth


after that go to Service then VPN add this line into additional Config

script-security 4
auth-user-pass-verify /tmp/quickAuth.sh via-env




now we open client config and add this into it

auth-user-pass
auth-retry interact






that all it need to make user authencation . you can make as many username as you like , just add as "jonh 2qwerty " jonh is user name and 2qwert as password




if someone try to connect without usename ans password in log you will see this

daemon.err openvpn[4572]: 92.40.202.154:50155 TLS Error: Auth Username/Password was not provided by peer
Dec 7 00:33:30 DD-WRT daemon.err openvpn[4572]: 92.40.202.154:50155 TLS Error: TLS handshake failed
Dec 7 00:33:30 DD-WRT daemon.err openvpn[4572]: 92.40.202.154:50155 Fatal TLS error (check_tls_errors_co), restarting
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Fri Dec 10, 2021 12:21    Post subject: Reply with quote
Thanks for sharing, the OpenVPN setup guide has a simple script but if you have many users using a separate file with username password is a viable option and then iterate through the script or using conditional awk, like your script, is an elegant solution.

As I hate backticks perhaps this will work?:

Code:
pass="$(awk -v usr=$username '$1==usr { print $2 }' /opt/userpass/auth)"
[[ -n $pass && $pass == $password ]] && { echo "Auth OK"; exit 0; }
exit 1


I will mention it in the guide, thanks again

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087


Last edited by egc on Sat Dec 11, 2021 7:31; edited 1 time in total
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 6291
Location: Texas

PostPosted: Fri Dec 10, 2021 12:34    Post subject: Reply with quote
egc wrote:
As I hate backticks...

seen you say that many times...
maybe time for a pair of glasses...
it does help with 'backticks' reading/writing Twisted Evil
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Fri Dec 10, 2021 12:51    Post subject: Reply with quote
I would opt for a better monitor Laughing

https://www.rtings.com/monitor/reviews/dell/ultrasharp-u4021qw

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Fri Dec 10, 2021 23:16    Post subject: Reply with quote
backticks: (Ever had a tick on your back??? I have, and I don't recommend it!)
On this I'm with @egc, as I can't opt for better eyes. Had laser surgery on one of them yesterday, but it won't make backticks suddenly distinguishable from apostrophes. These kinds of visual decisions in coding are generally made by young people, but they shouldn't be.

_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 6291
Location: Texas

PostPosted: Fri Dec 10, 2021 23:24    Post subject: Reply with quote
SurprisedItWorks wrote:
These kinds of visual decisions in coding are generally made by young people...

I do lots of copy/paste these days Razz
AND
I'm 15 yrs older than BrainSlayer iffin that gives you a clue Twisted Evil
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14246
Location: Texas, USA

PostPosted: Fri Dec 10, 2021 23:54    Post subject: Reply with quote
mrjcd wrote:
SurprisedItWorks wrote:
These kinds of visual decisions in coding are generally made by young people...

I do lots of copy/paste these days Razz
AND
I'm 15 yrs older than BrainSlayer iffin that gives you a clue Twisted Evil

I won't tell on myself too much, but @SurprisedItWorks probably has us both beat from what I recall. Cool Much love for us "old geezers" 'round here. Laughing

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Mon Dec 13, 2021 15:30    Post subject: Reply with quote
Well, I did finish my first programming course - Fortran - fifty years ago this month. And I brought up my first Unix system on a Vax 750 over 37 years ago now. So yeah, I have to admit to late middle age.
_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14246
Location: Texas, USA

PostPosted: Mon Dec 13, 2021 18:17    Post subject: Reply with quote
I doubt very many people on the forum even know Fortran or COBOL, let alone what a Vax is (was). I posted some nostalgic YouTube video links over the past couple of days elsewhere about the history of Unix and Linux, lol.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 6291
Location: Texas

PostPosted: Mon Dec 13, 2021 18:23    Post subject: Reply with quote
kernel-panic69 wrote:
...forum even know Fortran...

That's what the iMac firmware was written in ...
...well the original tray-load iMac anyways cause I had one --- got it August 1998 Twisted Evil
the-joker
DD-WRT Developer/Maintainer


Joined: 31 Jul 2021
Posts: 2146
Location: All over YOUR webs

PostPosted: Mon Dec 13, 2021 18:43    Post subject: Reply with quote
I think its high time mrjcd uses a different emoji, all look so angry all the time, no matter reply.

/me runs Cool

Im not as old as @SuprisedItWorks, but age matters not. The only thing that changes with age which is meaningful to me and which really matters is, perspective! That matters more than anything else.

/me runs again from posting meaningless offtopic nonsense.

_________________
Saving your retinas from the burn!🔥
DD-WRT Inspired themes for routers
DD-WRT Inspired themes for the phpBB Forum
DD-WRT Inspired themes for the SVN Trac & FTP site
Join in for a chat @ #style_it_themes_public:matrix.org or #style_it_themes:discord

DD-WRT UI Themes Bug Reporting and Discussion thread

Router: ANus RT-AC68U E1 (recognized as C1)


Last edited by the-joker on Mon Dec 13, 2021 18:50; edited 3 times in total
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14246
Location: Texas, USA

PostPosted: Mon Dec 13, 2021 18:48    Post subject: Reply with quote
I miss Classic MacOS / OS9. But Apple knew they had to do something to compete.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 6291
Location: Texas

PostPosted: Mon Dec 13, 2021 18:54    Post subject: Reply with quote
the-joker wrote:
... mrjcd uses a different emoji, all look so angry all the time...
blkt
DD-WRT Guru


Joined: 20 Jan 2019
Posts: 5700

PostPosted: Wed Dec 15, 2021 8:50    Post subject: Reply with quote
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6446
Location: UK, London, just across the river..

PostPosted: Wed Dec 15, 2021 11:11    Post subject: Reply with quote
haha back in the school days (my time): basic, pascal(turbo pascal), logo, fortran...ware pic one compulsory...than in the uni, there was a cobol, mumps, visual basic and java...my dad was one of the members of mumps users group Smile Smile that's gone forever...now SQL..
Funny how some of those ware done and dusted...now we have more efficient computers, way ahead of the IBM rooms with gigantic tapes spinning all day long, or the RISK architecture, or even before those, while i was spinning around my Dad i remember those perfocard's computers like late 70's, early 80's... gosh time fly's..

Am I off topic ... Embarassed Embarassed Rolling Eyes dang...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum