Skip to content

kylegrantlucas/pia-wg-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pia-wg-config

A fast, portable Wireguard config generator for Private Internet Access (PIA) VPN.

Go Version License: MIT

🌍 Region Selection (NOT Hardcoded!)

IMPORTANT: This tool supports ALL PIA regions through the -r/--region flag. The default region is us_california, but you can easily connect to any region:

# Connect to different regions
pia-wg-config -r uk_london USERNAME PASSWORD
pia-wg-config -r de_frankfurt USERNAME PASSWORD  
pia-wg-config -r au_sydney USERNAME PASSWORD
pia-wg-config -r japan USERNAME PASSWORD

List All Available Regions

To see all available regions before connecting:

pia-wg-config regions

This will show you the complete list of PIA server regions you can connect to.

πŸš€ Quick Start

Installation

go install github.com/kylegrantlucas/pia-wg-config@latest

Basic Usage

# Generate config for default region (us_california)
pia-wg-config USERNAME PASSWORD

# Generate config for a specific region
pia-wg-config -r uk_london USERNAME PASSWORD

# Save config to file
pia-wg-config -o wg0.conf -r de_frankfurt USERNAME PASSWORD

# Enable verbose output
pia-wg-config -v -r japan USERNAME PASSWORD

πŸ“– Command Reference

Main Command

pia-wg-config [OPTIONS] USERNAME PASSWORD

Arguments:

  • USERNAME - Your PIA username
  • PASSWORD - Your PIA password

Options:

  • -r, --region - Region to connect to (default: "us_california")
  • -o, --outfile - Output file for the config (default: stdout)
  • -v, --verbose - Enable verbose output
  • -h, --help - Show help

Subcommands

  • pia-wg-config regions - List all available PIA regions

🌐 Popular Regions

Here are some commonly used region codes:

Region Code Location
us_california United States - California
us_east United States - East Coast
uk_london United Kingdom - London
de_frankfurt Germany - Frankfurt
ca_toronto Canada - Toronto
au_sydney Australia - Sydney
japan Japan
singapore Singapore
netherlands Netherlands
sweden Sweden

Run pia-wg-config regions for the complete list.

πŸ’‘ Usage Examples

Connect to UK servers

pia-wg-config -r uk_london -o uk-wg.conf myusername mypassword
sudo wg-quick up uk-wg.conf

Connect to German servers

pia-wg-config -r de_frankfurt -o germany.conf myusername mypassword
sudo wg-quick up germany.conf

Quick connection (output to stdout)

pia-wg-config -r netherlands myusername mypassword > vpn.conf

πŸ”§ Integration Examples

Bash Script for Multiple Regions

#!/bin/bash
REGIONS=("uk_london" "de_frankfurt" "us_california" "japan")
USERNAME="your_username"
PASSWORD="your_password"

for region in "${REGIONS[@]}"; do
    echo "Generating config for $region..."
    pia-wg-config -r "$region" -o "configs/${region}.conf" "$USERNAME" "$PASSWORD"
done

Docker Usage

FROM golang:alpine AS builder
RUN go install github.com/kylegrantlucas/pia-wg-config@latest

FROM alpine:latest
RUN apk --no-cache add ca-certificates wireguard-tools
COPY --from=builder /go/bin/pia-wg-config /usr/local/bin/
ENTRYPOINT ["pia-wg-config"]

πŸ—οΈ Building from Source

git clone https://github.com/kylegrantlucas/pia-wg-config
cd pia-wg-config
go build -o pia-wg-config .

πŸ› Troubleshooting

Common Issues

"Region not found" error:

  • Run pia-wg-config regions to see available regions
  • Check your spelling of the region code
  • Region codes are case-sensitive

Authentication errors:

  • Verify your PIA username and password
  • Make sure your PIA subscription is active
  • Try connecting through the PIA app first to verify credentials

Network connectivity issues:

  • Check your internet connection
  • Try with verbose mode: -v flag
  • Some networks block VPN traffic

Getting Help

  1. Check the Issues page
  2. Run with -v flag for detailed output
  3. Verify your PIA account is active

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

git clone https://github.com/kylegrantlucas/pia-wg-config
cd pia-wg-config
go mod download
go test ./...

πŸ“‹ Requirements

  • Go 1.23 or later (for building)
  • Active PIA subscription
  • Wireguard client (for using generated configs)

πŸ” Security

  • This tool connects directly to PIA's official API endpoints
  • Your credentials are only used for authentication and are not stored
  • Generated configs contain your unique keys - keep them secure
  • Configs expire and need to be regenerated periodically

πŸ“š Background

Based on the manual-connections scripts provided by Private Internet Access. This Go implementation provides:

  • Portability - Single binary that runs anywhere
  • Speed - Fast config generation
  • Reliability - No external dependencies
  • Simplicity - Easy command-line interface

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ Star History

If this tool helped you, consider giving it a star! It helps others discover the project.


Note for Forkers: You don't need to fork this repository to change regions! Use the -r flag instead. This tool supports all PIA regions out of the box.

About

A Wireguard config generator for Private Internet Access

Resources

License

Stars

Watchers

Forks

Packages

No packages published