A bash
scripts that generates Wireguard configuration file for a NordVPN connection.
This guide assumes the use of Ubuntu. A similar install procedure will work on other distros.
First let's clone this project so that you'll have the script on your target Ubuntu system.
sudo apt install wireguard curl jq net-tools
Install NordVPN client
Execute the following command and follow the on screen instructions:
sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)
Login to your NordVPN account
The procedure differs if you have MFA
enabled on your account:
-
MFA
is ENABLED on your accountnordvpn login
This will return a URL link.
Open the link on any browser, on any machine and perform the login.
Cancel out of theOpen with
popup, and copy the link that is assigned to theContinue
link, under the message sayingYou've successfully logged in
.Back to the terminal
nordvpn login --callback "<The link you copied>"
And it will log you in.
-
MFA
is NOT ENABLED on your accountUse
legacy
username and password to login.Note: This will NOT work if you have
Multi Factor Authentication
enabled. (See above for theMFA
method)nordvpn login --legacy
After a successful login, please set NordVPN to use NordLynx
protocol.
sudo nordvpn set technology nordlynx
Generate Wireguard configuration files
The script is quite simple and can be run without parameters to generate a config file for the recommended server:
$ ./NordVpnToWireguard.sh
Getting configuration for recommended server...
Wireguard configuration file NordVPN-us1234.conf created successfully!
Requesting a specific country:
$ ./NordVpnToWireguard.sh --country Canada
Getting configuration for recommended server in Canada
Wireguard configuration file NordVPN-ca1234.conf created successfully!
Requesting a specific city
$ ./NordVpnToWireguard.sh --city Berlin
Getting configuration for recommended server in Berlin
Wireguard configuration file NordVPN-de1234.conf created successfully!
Requesting a specific country and city
$ ./NordVpnToWireguard.sh --country Japan --city Tokyo
Getting configuration for recommended server in Japan, city: Tokyo
Wireguard configuration file NordVPN-jp1234.conf created successfully!
Getting help:
$ ./NordVpnToWireguard.sh --help
Usage: NordVpnToWireguard [OPTIONS]
OPTION includes:
-v | --version - prints out version information.
-c | --country - Country to connect to (ex. Canada). If option is not provided, NordVPN will get a wireguard configuration for the recommended country, unless a valid city name is provided.
-s | --city - City to connect to (ex. Toronto). When country option is provided, NordVPN will look for the the city within the country and return the fastest server. If no country is provided, NordVPN will look up the fastest server for a city matching the name.
-h | --help - displays this message.
Use the generated Wireguard configuration files
Import the file/s with the Wireguard client in any platform and activate the VPN
.