Skip to content

OpenVPN on a Raspberry Pi

Create an openvpn user

To avoid conflicts with other users, create a new user for the VPN service and set a password for this user. In my case the user is called «openvpn».

1
2
3
4
5
6
# adduser «openvpn»
# passwd «openvpn»
# sudo usermod -a -G sudo «openvpn»
# mkdir /home/«openvpn»
# chown /home/openvpn «openvpn»
# chgrp /home/openvpn «openvpn»

Log in as «openvpn».

1
$ su - «openvpn»

Run the PiVPN install script

1
2
$ curl -L install.pivpn.io > pivpn.sh
$ chmod +x pivpn.sh

Once you are sure the script is not harmful in any way, run the installation script.

1
$ ./pivpn.sh
  1. Confirm the current network settings and make sure the shown IP address (eg. 192.168.2.110) is always assigned to this device by the router.
  2. Choose the user «openvpn».
  3. When asked, select UDP as a protocol.
  4. Confirm the default OpenVPN port 1194.
  5. Select ECDSA encryption strength. (Recommended: 256-bit)
  6. If you use DNS, enter the domain name.
  7. Reboot after the installation has finished

Add clients

To generate a client configuration, use:

1
$ pivpn add

Select a different username and password for each client. Copy the resulting ovpn file to your client device via scp and use it in your OpenVPN client.