Persistant OpenVPN Connection
Official kiosk documentation can be find here: http://porteus-kiosk.org/documentation.html
Porteus Kiosk section of the forum is unmaintained now. Its kept in a 'read only' mode for archival purposes.
Please use the kiosk contact page for directing your queries: https://porteus-kiosk.org/contact.html
Persistant OpenVPN Connection
Post#1 by Zeze21 » 04 Mar 2023, 13:31
i have a question:
Is there a way to "save" my OpenVPN Connection?
Maybe like remmina where i have to import the configuration file via run command?
Any help is greatly appreciated
Thank you all
Zeze21
Persistant OpenVPN Connection
Post#2 by AcnapyxoB » 04 Mar 2023, 13:59
You can use OpenVPN client.conf:
Code: Select all
# Sample OpenVPN config file
client
dev tun0
proto udp
remote my-server 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /path_of/cert_export_CA.crt
cert /path_of/cert_export_CLIENT.crt
key /path_of/cert_export_CLIENT.key
remote-cert-tls server
cipher AES-256-CBC
auth SHA1
pull
auth-user-pass /path_of/auth.cfg
auth-nocache
mute-replay-warnings
mute 20
float
Of course you can even start vpn by terminal:
Code: Select all
su
openvpn client.conf
AcnapyxoB
Persistant OpenVPN Connection
Post#3 by Zeze21 » 04 Mar 2023, 14:28
But how do I add a persistent connection there? So that the connection is available every time I start the client?
Zeze21
Persistant OpenVPN Connection
Post#4 by AcnapyxoB » 04 Mar 2023, 15:55
Can You explain, step by step, how You use that OpenVPN!
AcnapyxoB
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Persistant OpenVPN Connection
Post#5 by fanthom » 04 Mar 2023, 18:31
All connections are saved in /etc/NetworkManager folder which is persistent in the custom build which I have created.
Unless you are doing a PXE boot?
If yes then use 'run_command=' to download required files to /etc/NetworkManager folder (make sure you preserve a correct path for cert, etc).
Thanks
fanthom
Persistant OpenVPN Connection
Post#6 by Zeze21 » 19 Apr 2023, 16:48
I don't want remmina to automatically start.
Would this be correct:
Code: Select all
run_command=su - guest -c "mkdir -p /home/guest/.config/remmina; wget http://mysite.com/files/remmina.pref -O /home/guest/.config/remmina/remmina.pref; wget http://mysite.com/files/connection1.remmina; wget http://mysite.com/files/connection1.remmina; mkdir -p /etc/NetworkManager; wget http://mysite.com/files/profile.ovpn -O /etc/NetworkManager/profile.ovpn; &"
Also to i need to have the session persistence switched on or can I have (preferably) no persistence at all?
Zeze21
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Persistant OpenVPN Connection
Post#7 by fanthom » 19 Apr 2023, 17:18
2) You do not need full persistence for this. You could even pack all files into a module (its better than .zip as it preserves ownership/permissions) then download it, mount and copy files from it to the filesystem using 'run_command='.
Thanks
fanthom
Persistant OpenVPN Connection
Post#8 by Zeze21 » 22 Apr 2023, 22:23
Code: Select all
run_command=mkdir -p /etc/NetworkManager; wget http://mysite.com/files/vpn.ovpn -O /etc/NetworkManager/vpn.ovpn; nmcli connection import type openvpn file /etc/NetworkManager/vpn.ovpn; su - guest -c "mkdir -p /home/guest/.config/remmina; wget http://mysite.com/files/remmina.pref -O /home/guest/.config/remmina/remmina.pref; wget http://mysite.com/files/1.remmina -O /home/guest/.config/remmina/1.remmina; wget http://mysite.com/files/2.remmina -O /home/guest/.config/remmina/2.remmina;"
When the computer starts... the files all have 0 bytes...

after a couple of reboots the vpn connection has been downloaded correctly but unfortunately not the rdp connections....
I get the message sometime that the server is not ready/accessible now i was wondering since I want to carry my laptop with me and use in future new unseen wifi networks:
Is there an option to wait in the run_command until the laptop has a wireless connection?
EDIT
1.) DO NOT(!) try to have the run command check wether there is a connection established.... if you have no connection established during the first boot -> the computer will not continue loading and you will have to reinstall everything (at least i couldn't get it to work.
2.) I AM STUPID
the .remmina files have to go into /home/guest/.local/share/remmina/ ....then the rdp connections will show up
3.) I am not sooo stupid...
The files somehow still only have 0 bytes for whatever reason
If i execute the commands in ssh, it works perfectly fine.... I am at a loss
Zeze21
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Persistant OpenVPN Connection
Post#9 by fanthom » 24 Apr 2023, 06:38
You may have the network check enabled, just send it to the background.
This way remmina/VPN files will be downloaded as soon as network is available (e.g. you manually connect to the Access Point).
See documentation:
https://porteus-kiosk.org/parameters.html#run_command
Thanks
fanthom
Persistant OpenVPN Connection
Post#10 by Zeze21 » 24 Apr 2023, 07:09
I tried
while ! nmcli -t device show | grep -q "IP4.ADDRESS\[1\]:"; do
sleep 5
done
And why do the files always end up having 0 Bytes?
Zeze21
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Persistant OpenVPN Connection
Post#11 by fanthom » 24 Apr 2023, 08:00
2) there must be no network available when 'run_command=' operates
fanthom
Persistant OpenVPN Connection
Post#12 by Zeze21 » 24 Apr 2023, 10:31
This to my understanding means, that the commands will only be executed if there is an actual connection established. So how can 2) even be possible? If the commands are executed when a connection is established why are they apparently executed before?Description:
Run custom command during system startup. Your commands will be executed once network is established so utilities like rsync, wget and also graphical ones could work. Linux shell syntax is supported so its possible to execute commands one after another, send them to the background, perform tests, use pipes, etc ...
NOTE: Use following syntax to execute the command with a delay: ( sleep 10; your-command; ) &
If the parameter is not present then system will not execute any custom commands during startup.
I tried the following:
run_command=while ! nmcli -t device show | grep -q "IP4.ADDRESS\[1\]:"; do sleep 5 done &; mkdir -p /etc/NetworkManager; wget -q http://mysite.com/files/server.conf -O /etc/NetworkManager/server.conf; nmcli connection import type openvpn file /etc/NetworkManager/server.conf; su - guest -c "mkdir -p /home/guest/.config/remmina; wget http://mysite.com/files/remmina.pref -O /home/guest/.config/remmina/remmina.pref; mkdir -p /home/guest/.local/share/remmina; wget -q http://mysite.com/files/1.remmina -O /home/guest/.local/share/remmina/1.remmina; wget -q http://mysite.com/files/2.remmina -O /home/guest/.local/share/remmina/2.remmina;"
(I hoped that this would send the command to the background)
But no luck
Zeze21
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Persistant OpenVPN Connection
Post#13 by fanthom » 24 Apr 2023, 10:57
This is the case for standard kiosk ISO.
This is not the case for your custom build with Network Manager included.
I redirected you to documentation to find how sending processes to background works.
Your code has incorrect syntax and is also not reliable (nmcli reports IP4 address also for loopback interface so you always get true and thats why you always got 0 size files).
Here is ready to go solution:
Code: Select all
run_command= ( while true; do [ `route -n | grep -c " UG "` = 1 ] && { dunstify "Connection established"; break; } || { dunstify "Network not ready yet"; sleep 5; }; done; mkdir -p /etc/NetworkManager; wget -q http://mysite.com/files/server.conf -O /etc/NetworkManager/server.conf; nmcli connection import type openvpn file /etc/NetworkManager/server.conf; su - guest -c "mkdir -p /home/guest/.config/remmina; wget http://mysite.com/files/remmina.pref -O /home/guest/.config/remmina/remmina.pref; mkdir -p /home/guest/.local/share/remmina; wget -q http://mysite.com/files/1.remmina -O /home/guest/.local/share/remmina/1.remmina; wget -q http://mysite.com/files/2.remmina -O /home/guest/.local/share/remmina/2.remmina"; ) &
fanthom
Persistant OpenVPN Connection
Post#14 by Zeze21 » 24 Apr 2023, 12:04
Zeze21
- fanthom
- Moderator Team
- Posts: 5667
- Joined: 28 Dec 2010, 02:42
- Distribution: Porteus Kiosk
- Location: Poland
- Contact:
Persistant OpenVPN Connection
Post#15 by fanthom » 24 Apr 2023, 12:07
Code: Select all
route -n
fanthom