Search code examples
macosvpnpritunl

How to automatically authorise to VPN network with pritunl with username and password persisted in file on macos


Pritunl simple client is great, but it does not come with way to persist username and password for a user. Is there a way to read authorisation data form a file so login window would not have to pop up on every VPN connection?


Solution

  • On MacOS installed pritunl with configured profile for VPN network go to:

    cd /Users/[user1]/Library/Application\ Support/pritunl/profiles/[profile_hash].ovpn
    

    where profile_hash - would be alphanumeric hash like 028c16f93c....c6258 and user1 - your user obviously

    Open it in your editor and find line, with auth-user-pass and add path to file containing you authorisation credentials

    auth-user-pass /Users/user1/directory-to-keep-vpn-profile-data/auth.txt
    

    As Mat J pointed out: windows users may need to escape the backslash in the path with double backslash)

    auth.txt should be a plain txt file with just 2 lines:

    username
    password
    

    You should restart pritunl app now in case if it was on. If everything is valid login window should not appear but app should use your authorisation data! You can use debug option in case of any problems. Usually it would be that you path to the file is wrong or auth file contains some whitespace like characters that affect your entry.

    Keep in mind that your authorisation file is plain file. With solution above, your VPN account will be only as safe as account on machine where you put that file is.