Save OpenVPN Credentials for Automatic Login

NoxPengwin · November 25, 2024

Save OpenVPN Credentials for Automatic Login

When using OpenVPN with VPN providers, entering your credentials repeatedly can be annoying. This article shows you how to securely save your credentials in a file for hassle-free connections.


Steps to Save Credentials

Create a Credential File

  1. Open a terminal and create a text file:
    vim vpn-credentials.txt
    
  2. Add your username and password (provided by your VPN provider):
    username
    password
    

Secure the Credential File

To prevent unauthorized access, set proper permissions:

chmod 600 vpn-credentials.txt

This ensures only your user account can read the file.


Modify the OpenVPN Configuration File

  1. Open your VPN configuration file:
    vim <server-name>.ovpn
    
  2. Add or modify the following line to point to your credential file:
    auth-user-pass vpn-credentials.txt
    

Connect to the VPN

Use the updated configuration file to connect:

sudo openvpn --config <server-name>.ovpn

The VPN will now use the saved credentials and won’t prompt you.


Important Notes

File Location: If the vpn-credentials.txt file is not in the same directory as your .ovpn file, use the full path:

auth-user-pass /path/to/vpn-credentials.txt

Twitter, Facebook