I'm having this tricky problem trying to automatize a connection to a VPN. I have to ask for a password every time I want to connect, but I've already managed to request and parse it. The problem now is, when I execute nmcli to connect to the VPN, it gives me this error
Active connection state: unknown Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/11 state: VPN connecting (need authentication) (2) state: VPN connecting (3) state: VPN connecting (getting IP configuration) (4) Error: Connection activation failed: unknown reason.
However, if I execute this as a command from a terminal, it works just fine. This is really driving me mad because I have no idea of what could it possibly be. Here is the source of the script:
# [...] fetch $password sed -i 's/^password=.*$/password=$password/g' $VPNFILE sudo grep password $VPNFILE # $password is actually modified on the file sudo nmcli con up id $VPN
$VPNFILE is the /etc/NetworkManager/system-connections associated file. Googling the error I found this thread with a similar problem, where the error was a wrong password, but that's not the problem here since grep gives the expected output.
Any ideas about the logic behind this issue and/or how to fix it?
Thank you for your time.