Client Web UI?

How to customize and extend your OpenVPN installation.

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

Post Reply
Mindustries
OpenVpn Newbie
Posts: 3
Joined: Sun Apr 12, 2020 10:01 am

Client Web UI?

Post by Mindustries » Sun Apr 12, 2020 10:10 am

Hi everyone, I ended up here after a few unproductive searches on Google. I hope I am not asking something OT or already answered.

I am trying to configure a headless RaspberryPI (v3) as a VPN passthrough for multiple VPNs. I am at the very beginning, i.e. the configuration of the VPN - and it works.

I will look into adding a second eth and configuring two VPNs later on. Right now, I am looking for an alternative way to SSH + commands to switch VPN on-the-fly. I would like to be able to change the connection to a different server without having to connect to the RasbPi via SSH every time. I was wondering if there is an OpenVPN web interface for the client (i.e. to select a server and launch the connection).

Thanks!

bitchange
OpenVpn Newbie
Posts: 17
Joined: Sun Apr 12, 2020 8:28 pm

Re: Client Web UI?

Post by bitchange » Sun Apr 12, 2020 8:56 pm

Hi Mindustries,
I had the similar need and I am trying to solve it by creating a script that changes the openvpn config file to the server I need to connect to.
If you also trying to run the script from a windows machine and dont want to login ssh all the time, you need to make a .bat file that has code to do the ssh for you and call the script.
I give you a few examples and my issue... who knows.. maybe you solve that and we mutually help each others...
So...
preface: - I use systemd -
- First of all, you have to have the .conf files you need at the /etc/openvpn folder.
in my case I use PIA commercial VPN provider and I chose a few servers I need.

- I created a script to change the /etc/default/openvpn file.
This script Server_change look like this:
======
#!/bin/bash

# sript to checngeb the PiVPN exit country
# this is to change exit coutry to:
# netherlands
iNetherlands"
# here I look for the AUTOSTART variable and add the value to it in the openvpn file (that obviously I previously uncommented).
sudo sed -i "/^AUTOSTART/c\AUTOSTART=\"$i\"" /etc/default/openvpn

# now need to restart the systemctl and the openvpn service with its config file
sudo systemctl daemon-reload
sudo systemctl restart openvpn@Netherlands.service

=======
I did this by doing: sudo nano <file_name>
Dont forget to change mod and have it executable (chmod)

now, I do ssh to my pi and and send a .sh file to it
if you are in windows, you can create a .bat file that loooks like that (this is only a hint):

@echo off
:: thi file will run a .sh file to change the openvpn server in the PiVPN
ECHO =======================
ECHO PiVPN server change
putty -ssh <user>@192.168.x.x -pw "your_super_safe_password" -m "<local path to your script to send to the pi>"


At this point, you have to have a local script called (example): Server_change.sh somewhere in your local machine.
Point your .bat file to it and have putty installed.
Thats should do the trick.

MIND that all this I mention I do it for gathering the Pi temperature (obviously with a different script).
But the script I mention above, is a actual script that I run after SSH in to the pi.

Now I tell you my issue:
As I have several server.conf in the /etc/openvpn folder, clearly I have to define the one I want to use in the /etc/default/openvpn file by the mean of changing the AUTOSTART= value.
that works well.
however, it seems that openvpn client keeps rotating all servers in the folder as if I had AUTOSTART="all" (of maybe it loads all profiles )
thats my problem!
If you have better luck in that, I like to know how you did it.


Good luck
I hope I could manage to help you in your quest
bitchange

Mindustries
OpenVpn Newbie
Posts: 3
Joined: Sun Apr 12, 2020 10:01 am

Re: Client Web UI?

Post by Mindustries » Fri Apr 17, 2020 7:13 pm

Thank you @bitchange, that is very useful. I started going down the same route when I realised that my main requirement is to switch VPN from my iPhone - and that's when I realised that the solution is much simpler than it looks like since Shortcuts allows to run scripts over SSH (and pass variables):

Image

bitchange
OpenVpn Newbie
Posts: 17
Joined: Sun Apr 12, 2020 8:28 pm

Re: Client Web UI?

Post by bitchange » Sat Apr 18, 2020 10:04 am

@Mindustries thats certainly a nice solution.
It might be interests me as well as I keep having a strange server rotation. even now that I eliminated (deleted) ALL servers config files but one, it keep disregarding it and somehow moving to a US (I guess ) default server profile!!
What is the software you use on your phone to change server at the VPN server you have?
I dont use iphone... I hope your suggestion works on android as well.
Thanks

Mindustries
OpenVpn Newbie
Posts: 3
Joined: Sun Apr 12, 2020 10:01 am

Re: Client Web UI?

Post by Mindustries » Sat Apr 18, 2020 8:54 pm

I am not sure how that solution would translate on Android as I have never used one.
Apple Shortcuts allows defining actions from a library and I am doing the following:
  1. * Ask for input to the user about which country they want to connect to
    * Based on the answer I am using the pre-defined action that allows to connect to an SSH server and run a script passing a variable
    * For the variable, I have simply associated a country (the input from the user) to one of the available configurations for that country
I also wanted to scrape https://nordvpn.com/servers/tools/ to get the best server based on your location, but the output is generated by a script and it's not available in the page source - I haven't found a way to fetch the server so far.

On Android, I would image you have to use something like Tasker? Something like: https://android.stackexchange.com/quest ... inal-shell

bitchange
OpenVpn Newbie
Posts: 17
Joined: Sun Apr 12, 2020 8:28 pm

Re: Client Web UI?

Post by bitchange » Mon Apr 20, 2020 6:06 pm

@Mindustries
thanks

Post Reply