How to smoothly login through openvpn with 2 factor auth?

I have a openvpn set up with 2 factor authentication via Google Authenticator app.

In connection details I filled User name and Password (User key password empty). When I login for the 1st time I get popup to fill in authentication code from Google app. After I do that though, the passwords gets overriden with this number code from the app. So next time I try to login there is popup for password and after that another popup for the Google app.

Can this be somehow fix to either:

  • save the password and show popup only for Google app
  • save the password and use some sort of script/app/hack so the authentication code from Google is filled automatically? (So I don't have to deal with popups? :) )

It's fresh installation of Ubuntu 19.10

9

1 Answer

It's not solution, but workaround

Guide

  1. Expected that VPN successfully configured.imageimage

    Note: select "Store the password for all users"image

  2. Get the list of VPN connections in command line, and find the target connection:

    nmcli connection show

    image

  3. Create a post-down script file, which will run every time when connection closed:

    sudo touch /etc/network/if-post-down.d/overwrite-vpn-password
  4. Put next content inside:/etc/network/if-post-down.d/overwrite-vpn-password

    #!/bin/sh
    nmcli connection modify NAME_OR_UUID vpn.secrets password=MY_PASSWORD

    image

  5. Make file executable:

    sudo chmod +x /etc/network/if-post-down.d/overwrite-vpn-password
  6. Done!

What's happen?

When you enter 2FA code, and VPN connection succeed, it updates secret password. This script will be executed every time when ANY connection closed (VPN for example), and will modify secrets of connection config using nmcli with hardcoded values.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like