3

Currently I am using openvpn3 client to connect to vpn server as

openvpn3 session-start --config /home/user/client.ovpn

then it asks for username and password.

Is there any easy way to pass username and password. Because everytime to enter username and password is annoying

Santhosh
  • 9,965
  • 20
  • 103
  • 243

3 Answers3

5

You can pass username and password with printf using \n as a delimiter:

printf "MY_USERNAME\nMY_PASSWORD\n" | openvpn3 session-start --config client.ovpn
SquareWhite
  • 51
  • 1
  • 2
1

openvpn3 session-start as per https://github.com/OpenVPN/openvpn3-linux

See the instructions on https://community.openvpn.net/openvpn/wiki/OpenVPN3Linux how to install pre-built OpenVPN 3 Linux packages on Debian, Ubuntu, Fedora, Red Hat Enterprise Linux, CentOS and Scientific Linux.

When I did an upgrade to Fedora 36 the latest openvpn3-linux v18 client was built in. Did not have to manually upgrade / install it:

openvpn3-admin version --services

e.g: previous v17 suddenly stopped working spend 10 hours trying to debug with many "openvpn3 session-start":

openvpn3 config-import --config profile.udp.ovpn --persistent
openvpn3 config-manage --config profile.udp.ovpn --enable-legacy-algorithms true --show
openvpn3 session-start --config profile.udp.ovpn
openvpn3 sessions-list 
openvpn3 session-manage --config profile.udp.ovpn --disconnect

Actually thinking it was a cipher AES-256-CBC legacy issue that others were having. It was not for some reason, permissions on install of the OpenVPN3 Linux client? as it was NOT creating a TUN. So I made one myself (that was the actual issue):

sudo ip tuntap add name tun0 mode tun
sudo ip link show

and it connected after asking for VPN Username & Password, so added those to text file login.txt in the profile directory and auth-user-pass login.txt to profile.udp.ovpn so it would pass username and password automatically.

Another solution to pass the username and password is to use openvpn3-autoload

FYI more openvpn3-client session start help is here: https://github.com/OpenVPN/openvpn3-linux/issues?q=cipher

social
  • 329
  • 3
  • 8
  • OpenVPN3 does not support `auth-user-pass`: https://openvpn.net/blog/openvpn-3-linux-and-auth-user-pass/ – Hubbitus Jan 27 '23 at 14:26
0

You can use this simple python script to connect to VPN:

import pexpect
from pexpect import popen_spawn

commands = "openvpn3 session-start --config profile-40.ovpn"
commands_list = commands.split(" ")
username = "x"
password = "x"

session = pexpect.popen_spawn.PopenSpawn(commands)
session.expect("Auth User name: ")
session.sendline(username)
print("first_done")

session.expect("Auth Password: ")
session.sendline(password)
print("second_done")