How to I set OpenVPN to use passwords?

Android device VPN setup requires passwords, not keys, so how to I configure OpenVPN for that?

I'm looking at this guide: https://www.linode.com/docs/networking/ … d-debian-7">https://www.linode.com/docs/networking/vpn/secure-communications-with-openvpn-on-ubuntu-12-04-precise-and-debian-7

11 Replies

@John Henry Eden:

Android device VPN setup requires passwords, not keys, so how to I configure OpenVPN for that?

I'm looking at this guide: https://www.linode.com/docs/networking/ … d-debian-7">https://www.linode.com/docs/networking/vpn/secure-communications-with-openvpn-on-ubuntu-12-04-precise-and-debian-7

What OpenVPN client are you using? I just verified that https://play.google.com/store/apps/deta … pn.openvpn">https://play.google.com/store/apps/details?id=net.openvpn.openvpn works just fine with certs/keys (embedded in the .ovpn profile that you import).

Edit: You may want to look at https://community.openvpn.net/openvpn/w … nPage#lbAV">https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage#lbAV for some details on how to put the certificates inline.

I also use that openvpn client on my phone and other android devices, and can confirm it works just fine with key based authentication.

As long as it doesn't require root, good find.

I was using the settings before.

What's the IPtables rule to open the default port on the firewall?

EDIT

When I tried to use that, it only seems to have options for importing a profile from a website.

@John Henry Eden:

As long as it doesn't require root, good find.

I was using the settings before.

What's the IPtables rule to open the default port on the firewall?

It doesn't require root, only a somewhat modern Android version (4.x).

As for "the settings", I don't believe stock Android has OpenVPN in the normal vpn settings, so I suppose it depends on what exactly you're running.

@John Henry Eden:

EDIT

When I tried to use that, it only seems to have options for importing a profile from a website.

A local file works fine.

How to I create the .ovpn file?

What should I use in IPtables to open the port?

@John Henry Eden:

How to I create the .ovpn file?

What should I use in IPtables to open the port?

The .ovpn file is just an OpenVPN configuration file, just like the one in the guide you referenced initially.

As I mentioned before, I think you'll want to put the certificates/keys inline instead of referencing separate files, though.

With just raw iptables it would be something like this:

iptables -A INPUT -p udp -m udp --dport 1194 -j ACCEPT

However, you probably want to look at whether you are using some firewall manager like ufw, firewalld, etc. If so, you'll probably want to use that to add your new rule.

Thanks. I'm going use a file that contains iptables instructions, as suggested in the Linode guide.

So the .opvn file just contains the paths to the various files created by the VPN? Is that something that I have to set up on the device?

@John Henry Eden:

Thanks. I'm going use a file that contains iptables instructions, as suggested in the Linode guide.

So the .opvn file just contains the paths to the various files created by the VPN? Is that something that I have to set up on the device?

The .ovpn file contains ALL of the openvpn client configuration.

If you're following the Linode guide, with the addition of putting the certs/keys inline, it would look like this (same template as suggested there):

##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server.     #
#                                            #
# This configuration can be used by multiple #
# clients, however each client should have   #
# its own cert and key files.                #
#                                            #
# On Windows, you might want to rename this  #
# file so it has a .ovpn extension           #
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.

remote example.com 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nogroup

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.

 <ca>-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----</ca> 

 <cert>-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----</cert> 

 <key>-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----</key> 

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
ns-cert-type server

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20

I have the files:

ca.crt
sasha.crt
sasha.key

So the way I set up the file would be like this?

##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server.     #
#                                            #
# This configuration can be used by multiple #
# clients, however each client should have   #
# its own cert and key files.                #
#                                            #
# On Windows, you might want to rename this  #
# file so it has a .ovpn extension           #
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.

remote ehrenburg.akula.sturmkrieg.ru 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nogroup

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.

 <ca>-----BEGIN CERTIFICATE-----
/path/to/ca.crt
-----END CERTIFICATE-----</ca> 

 <cert>-----BEGIN CERTIFICATE-----
/path/to/sasha.crt
-----END CERTIFICATE-----</cert> 

 <key>-----BEGIN PRIVATE KEY-----
/path/to/sasha.key
-----END PRIVATE KEY-----</key> 

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
ns-cert-type server

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20

Just added that file to the device and I got this error on trying to connect:

open ssl core error polarssl error parsing ca certificate : pem - pem string is not as expected : base64 - invalid character in input

EDIT

I literally copied that file, with the example file paths.

EDIT

So am I supposed to copy the values from those key files into these sections?

 <ca>-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----</ca> 

 <cert>-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----</cert> 

 <key>-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----</key> 

EDIT

I just configured the .ovpn file the way that the guide describes. The connection keeps timing out when I try to connect the Android client.

EDIT

Just finished with the guide, and the connection still times out.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct