[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

¡Esta es una revisión vieja del documento!


OpenVPN

OpenVPN es un programa de código abierto que implementa técnicas de red privada virtual (VPN) (por sus siglas en ingles) para crear conexiones seguras punto a punto o sitio a sitio en configuraciones enrutadas o puenteadas e instalaciones de acceso remoto. Utiliza un protocolo de seguridad personalizado que utiliza SSL/TLS para intercambio de claves. Es capaz de atravesar traductores de direcciones de red (NAT) y cortafuegos. Fue escrito por James Yonan y se publica bajo la Licencia Pública General de GNU (GPL).

OpenVPN les permite autenticarse entre sí utilizando una clave secreta precompartida, certificados o nombre de usuario/contraseña. Cuando se utiliza en una configuración de servidor multicliente, permite que el servidor libere un certificado de autenticación para cada cliente, utilizando la firma y la autoridad de certificación. Utiliza la biblioteca de cifrado OpenSSL ampliamente, así como el protocolo SSLv3/TLSv1, y contiene muchas características de seguridad y control.

Cómo usar OpenVPN

Es muy simple si ya tiene una configuración lista para usar por cualquier proveedor openvpn.

# openvpn --config yourconfig.ovpn

Si no tiene una configuración que pueda usar, debería mirar en /etc/openvpn. Slackware tiene una configuración de ejemplo con algunos buenos consejos allí.

Using OpenVPN with the i3 status bar

I'm using the i3 window manager with dmenu and the i3statusbar. You can configure the bar to show you if you're running openvpn or not. The i3status.conf lies in /etc/ if installed with the SlackBuild.

You have to start openvpn with an additional –writepid /path/to/your.pid.

For example:

openvpn --config /etc/openvpn/vpn.ovpn --writepid /var/run/pid/openvpn.pid

To use the build in feature you have to edit the config file. Look for the

run_watch VPN {
        pidfile = "/var/run/something.pid"
}

block and change the something into your choosen pid name. In this case:

run_watch VPN
        pidfile = "/var/run/openvpn.pid"
}

Rebuilding OpenVPN to read your login from file

Since I wanted my openvpn connection to start automatically when I connect my Thinkpad to the dock I thought it would be usefull to add the 'password safe' feature. ('password safe' setting allows you to store your username and password in a file for scripting) This feature is not installed by default. You have to add it to the slackbuild and recompile the package.

Start by grabbing the source and slackbuild from one of the Slackware mirrors.

http://mirrors.slackware.com/slackware/slackware64-14.0/source/n/openvpn/

Change the mirror for your needs, for example -current.

In the next step we will change the openvpn.SlackBuild file.

Open the slackbuild file with you editor of choice.

For vim do:

$ vim openvpn.SlackBuild

Now look for this block of code:

./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --sysconfdir=/etc/openvpn \
    --localstatedir=/var \
    --docdir=/usr/doc/openvpn-${VERSION} \
    --enable-lzo \
    --enable-iproute2 \
    --build=$ARCH-slackware-linux

Add the marked line to it.

./configure \
    --prefix=/usr \
    --libdir=/usr/lib${LIBDIRSUFFIX} \
    --sysconfdir=/etc/openvpn \
    --localstatedir=/var \
    --docdir=/usr/doc/openvpn-${VERSION} \
    --enable-lzo \
    --enable-iproute2 \
    --enable-password-save \ #add this line!
    --build=$ARCH-slackware-linux

Save the file, make it executable and rebuild the package with

$ chmod +x openvpn.SlackBuild && ./openvpn.SlackBuild

The new package should be in the /tmp directory.

Install it with:

# upgradepkg --install-new /tmp/yourpackage.tgz

Now you are able to load your login and password from a file. The file should contain two lines of text:

username
password

Save the file and make it only readable for the owner.

$ chmod 700 yourfile

Lastly add the line below to your openvpn config.

auth-user-pass /path/to/your/passwordfile

Now you should be able to login without typing your password everytime.

Sources

 es:howtos:security:openvpn ()