2

I am using openvpn to connect with other server, the problem is that i run it like this

openvpn configfile.ovpn ... and it locks my shell, so, if I close it, the shell gets closed, I was looking for a way to initialize it as daemon, sending my configfile, but I could not find any, I saw the param --configfile but seems like I did not work the way I used it... any idea or way to do it??

I am using linux Debian 6

Thanks

Edit: My .ovpn file is like this:

dev tap
client
proto tcp-client
ca /etc/openvpn/ca.crt
cert /etc/openvpn/client.crt
key /etc/openvpn/client.pem
tls-remote "/O=WatchGuard_Technologies/OU=Fireware/CN=Fireware_SSLVPN_Server"
remote-cert-eku "TLS Web Server Authentication"
remote someIP 
persist-key
persist-tun
verb 3
mute 20
keepalive 10 60
cipher BF-CBC
auth MD5
float 1
reneg-sec 3660
nobind
mute-replay-warnings
auth-user-pass
mgorven
  • 30,615
  • 7
  • 79
  • 122
user156355
  • 99
  • 1
  • 3
  • 9

1 Answers1

7

You should use Debian's initscript for OpenVPN. Place your configuration in /etc/openvpn/foo.conf and then start it like this:

sudo service openvpn start foo

The service will be automatically started when the system boots, if you don't want this edit /etc/default/openvpn and change this line:

AUTOSTART="none"

Edit: You can get the client to read the username and password from a file specified with the auth-user-pass directive. This file should contain the username on the first line and password on the second.

auth-user-pass /etc/openvpn/password
mgorven
  • 30,615
  • 7
  • 79
  • 122
  • thanks! im trying, but I cant find any docs about an example of how make the foo.conf or openvpn.conf, could you suggest me some links please? – user156355 Feb 21 '13 at 22:49
  • @user156355 It's exactly the same configuration file that you're already using. – mgorven Feb 21 '13 at 22:53
  • Thank you!! I moved all my files, configfile.ovpn and the crt (just in case) and I tried service openvpn start client (and client.ovpn) and I get an error, something like this "Starting virtual private network daemon:No such VPN: client.ovpn ... failed!" any idea? – user156355 Feb 21 '13 at 22:57
  • @user156355 Check `/var/log/syslog`. You may need to adjust the paths to files like certificates. – mgorven Feb 21 '13 at 23:00
  • my log file is empty, I updated my post with the code of my conf, could you please give it an eye? – user156355 Feb 21 '13 at 23:09
  • @user156355 Actually, I see your problem. You must name your config `somename.conf` and just call it `somename` when starting it (as in my example). – mgorven Feb 21 '13 at 23:10
  • thank you @mgorven , I tried only sudo service openvpn start without my .conf file, and when it starts asks me for user/password and then works, but... there is any way to include it? I found this function --auth-user-pass ... is it correct? – user156355 Feb 21 '13 at 23:22
  • @user156355 See my edit. – mgorven Feb 21 '13 at 23:26