Can't start OpenVPN as a service using init script

This forum is for admins who are looking to build or expand their OpenVPN setup.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Locked
chrisedes
OpenVpn Newbie
Posts: 2
Joined: Thu Mar 10, 2011 4:01 pm

Can't start OpenVPN as a service using init script

Post by chrisedes » Thu Mar 10, 2011 4:18 pm

OK, so I browsed everything in this forum under Server Administration, and viewed any thread which appeared remotely relevant. I've also done extensive Google searches and gone through the documentation online, both on openvpn.net and elsewhere. So I can only assume I am missing something incredibly obvious :)

I have configured OpenVPN and it works great. It is super awesome... with one little problem. I can run OpenVPN from a shell as "openvpn <config file>" and it does not prompt me for a username and password. I can run OpenVPN from a shell as "openvpn --daemon --writepid /var/run/openvpn/this.pid --config server.conf --cd /etc/openvpn" and it does not prompt me for a username and password. I copied this from the init script.

However, when I type "service openvpn start" I am asked for an "Auth Username" and "Auth Password" and OpenVPN will not start unless I provide appropriate credentials. If I do provide them, it works. This is a problem because I would like OpenVPN to come up automatically if the server is restarted, and I will not always be there at a console to enter the username and password.

(I suppose for some reason it may work when run as part of the normal startup process, and only because I am manually typing "service openvpn start" does it ask for credentials. However I can't test this now, and it would make no sense to me anyway.)

I am not using client certificates, but rather the PAM module "/usr/share/openvpn/plugin/lib/openvpn-auth-pam.so" . Perhaps this has something to do with it, but again I don't understand why I can run it as a daemon from a shell with no problem, and only experience undesired behavior when using the init script.

Clients can connect just fine with usernames and passwords. I am also using the tls-auth key. None of the private keys require passwords to access them. I have administered several certificate authorities using OpenSSL and I am confident this is not the problem.

So..... what's the deal? I am usually one of those "never ask for directions" guys but this has me stumped. Thanks for any help you can provide.

User avatar
Bebop
Forum Team
Posts: 301
Joined: Wed Dec 15, 2010 9:24 pm

Re: Can't start OpenVPN as a service using init script

Post by Bebop » Fri Mar 11, 2011 3:34 am

How many .conf files reside in your OpenVPN directory? (/etc/openvpn/ or whatever your default is)

Server.conf doesn't need a password, so to me it sounds like your problem is that you also have a client.conf in your directory.

I can almost guarantee that your answer will be that you have more than 1 .conf file in your openvpn dir, and that 1 of the .conf files is a client.conf.

FYI: 'service openvpn start' will execute every .conf file as a daemon. You should move any unwanted .conf to another dir (sub dir is ok).
The cure for boredom is curiosity

chrisedes
OpenVpn Newbie
Posts: 2
Joined: Thu Mar 10, 2011 4:01 pm

Re: Can't start OpenVPN as a service using init script

Post by chrisedes » Fri Mar 11, 2011 6:56 am

You are 100% correct! I knew it was something obvious. I looked right at the part in the init script where it cycled through the .conf files, and it never occurred to me that it was trying to execute as a client. It makes perfect sense now. Thanks!

This thread can be marked as resolved.

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Can't start OpenVPN as a service using init script

Post by maikcat » Fri Mar 11, 2011 9:26 am

ok then

i am closing topic


michael
Amiga 500 , Zx +2 owner
Long live Dino Dini (Kick off 2 Creator)

Inflammable means flammable? (Dr Nick Riviera,Simsons Season13)

"objects in mirror are losing"

Locked