Steam Deck

Steam Deck

Ben Bernanke May 27, 2023 @ 10:41pm
Script to Configure OpenVPN Server Connections through KDE
I have private internet access vpn and the client wasn't working.
the client works if you reinstall gcc (which reinstalls glibc I think).
But I didn't know that so I made a script to help me import all the .ovpn files into KDE connections.

I ran this and it worked for me. I'm not a programmer or a network engineer. I can't be sure this won't harm your computer or compromise your connection. use at your own risk.
This is like scraps that I put together bc I was doing it through the kde gui for each file and it sucked so then I wrote the script. But I never polished it up bc I figured out how to get the GUI working which I much prefer.

I was really hoping someone more knowledgeable would adapt the script bc it's simple to use nmcli command to import the certs and maybe they didn't think to do it.
This might be useful if you have a vpn without a gui that works through the deck desktop.

This doesn't automate the password entry. I just type it each time I connect to a server.

Here is a good thread on installing ovpn on steamOS

https://steamcommunity.com/app/1675200/discussions/0/3466100515586309793/

there's an eovpn app in flatpak store. maybe that will do this for you. in discover.
================================================================
This is how I did it manually (also explains what the script is trying to do)
I copied these from someone else's thread on how to get nord working through openvpn

(1) You download .ovpn files from pia website.

I think you need to be careful when doing this.
Here is their blog post linking the files:
https://helpdesk.privateinternetaccess.com/kb/articles/where-can-i-find-your-ovpn-files

And I think the link I used was
https://privateinternetaccess.com/openvpn/openvpn-strong.zip

I would be careful of somebody putting a malicious link up. I'm not 100% sure these are right.


(2) save them to the /etc/openvpn folder
sudo cp ~/Downloads/openvpn-strong.zip /etc/openvpn

the download is compressed, expand it

sudo unzip openvpn-strong.zip

You don't need the .zip file anymore

sudo rm openvpn-strong.zip

(3) each .ovpn file has a certificate embedded in it.

(4) on KDE desktop, open "System Settings", in the column on the left, scroll down to "Network" header.
under that, click "Connections".

(5) Connections has its own lefthand column. At the bottom of it are "+","-".
Click "+" to create a new vpn connection. "+" opens its own popup menu, at the bottom of it, under the "Other" heading, choose "Import VPN connection" then click "create".

(6) This will open your file explorer, navigate to rootfs/etc/openvpn (where you saved your .ovpn files)
Select the .ovpn file that has the same name as the server you want to connect to.

(7) You will be prompted to copy your certificate to "/home/deck/.local/share/networkmanagement/certificates"
select "yes".

(8) Go back to the KDE Network Connections GUI (steps 4-5).
You will see an entry with the same name as the .ovpn file that you selected in step 6.

(9) In the fields on the right, and makiing sure the "VPN" tab is selected,
enter your username and password that pia provides you
(the same one you enter into the pia client to logon to pia).
(You have to enter this for each server).
Then clicke "apply" in the lower right

(10) Click on the desktop or taskbar to minimize the KDE Network Connections GUI.

(11) In the taskbar/panel on the lower right, there's an internet or wifi connection icon.
This is where you normaly click to connect to your wifi.
Left-click it to bring up the connections menu.

(12) Make sure you are connected to your wifi/ethernet/whatever as usual. Don't close this.
There's a line underneath that and that should show a new connection with the same name you set up
in the KDE Network Connections GUI.

(13) click "connect" to the right on your new connection to connect to that pia/vpn server.

(14) If you connect succesfully, you should see the vpn connection above the white line and under your wifi connection.
If you don't connect succesffully probably check your username/password in the KDE Network Connections GUI. If that doesn't work try a new server becasue that server might just be down.
If none of the servers work, idk what to do.

(15) Go here to verify that you are connected to the vpn server of your choice:
https://www.privateinternetaccess.com/what-is-my-ip


Each certificate is a string inside the .ovpn file in /etc/openvpn

Here is the script. It does the above but for every server
(.ovpn file). I guess the gist of this is that each 'connection'
entry in kde is just a nmcli file entry so if you loop over the
.ovpn files and add them and the certs to ncmli and then mod
those with your vpn username, it adds them all by hand.
==============================================
# install openvpn
sudo pacman -S networkmanager-openvpn

# Download the ovpn .zip file from PIA
# and save it here:d /etc/openvpn

# decompress the ovpn .zip file
sudo unzip openvpn-strong.zip

# change dir to ovpn config dir
cd /etc/openvpn


# need to turn all the .ovpn files into connections with nmcli
# (you will still have to enter your password every time you connect to a
# new server for the first time).
# I don't want to save the pwd in a script file bc I don't know how to do that
# securely.
# This will add all the servers. If you only want some of them, it's best
# to do it by hand.
#you have to cd into the folder with the .ovpn files before you run the below.
#for me it was here:
#make sure you're still in cd /etc/openvpn

#I apologize for how bad I am at bash.
#Add all files ending in .ovpn as connection
sudo find . -type f -name "*.ovpn" -exec nmcli connection import type openvpn file {} \;

#add username to the connection (first it removes .ovpn from filename)
ls | grep .ovpn | sed s/.ovpn/ | xargs -I '{}' nmcli connection modify '{}' +vpn.data username=yourVPNUserName
Last edited by Ben Bernanke; May 31, 2023 @ 12:54pm
Date Posted: May 27, 2023 @ 10:41pm
Posts: 0