Skip to content

anupcshan/tscloudvpn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


tscloudvpn

Go Reference License

tscloudvpn is a tool for automatically managing VPN instances across multiple cloud providers with Tailscale/Headscale integration. It provides a web interface for easy management of cloud VPN exit nodes.

Features

  • Support for multiple cloud providers:
    • DigitalOcean
    • AWS EC2
    • Google Cloud Platform (GCP)
    • Linode
    • Vultr
  • Integration with both Tailscale and Headscale control APIs
  • Automated instance creation and management
  • Web-based management interface
  • Real-time instance status monitoring
  • SSH key support for instance access

Prerequisites

  • Go 1.23 or later
  • SSH public key for instance access
  • API credentials for your chosen cloud provider(s)
  • Tailscale account with OAuth client ID and secret, or Headscale API key and URL

Installation

go install github.com/anupcshan/tscloudvpn/cmd/tscloudvpn@latest

Configuration

tscloudvpn supports both YAML configuration files and environment variables. The configuration file is searched for in the following locations:

  1. $XDG_CONFIG_HOME/tscloudvpn/config.yaml
  2. ~/.config/tscloudvpn/config.yaml
  3. ~/.tscloudvpn.yaml

Configuration File (Recommended)

Example config.yaml:

ssh:
  public_key: "ssh-rsa AAAA..."

control:
  type: "tailscale"  # or "headscale"
  tailscale:
    client_id: "..."
    client_secret: "..."
    tailnet: "..."
  headscale:
    api: "..."
    url: "..."
    api_key: "..."
    user: "..."

providers:
  digitalocean:
    token: "..."
  gcp:
    credentials_json: "..."
    project_id: "..."
    service_account: "..."
  vultr:
    api_key: "..."
  linode:
    token: "..."
  aws:
    # Either specify the credentials directly
    access_key: "..."
    secret_key: "..."
    session_token: "..."
    # ... or use the shared config dir
    shared_config_dir: "~/.aws"  # optional
    # ... or use the AWS_ environment variables

Environment Variables (Legacy Support)

The following environment variables are still supported for backward compatibility:

Common Configuration

  • SSH_PUBKEY: Your SSH public key for instance access

Tailscale Configuration

  • TAILSCALE_CLIENT_ID: OAuth client ID
  • TAILSCALE_CLIENT_SECRET: OAuth client secret
  • TAILSCALE_TAILNET: Your tailnet name

Headscale Configuration (Alternative to Tailscale)

  • HEADSCALE_API: Headscale API endpoint
  • HEADSCALE_URL: Headscale URL
  • HEADSCALE_APIKEY: Headscale API key
  • HEADSCALE_USER: Headscale username

Cloud Provider Configuration

Configure your chosen cloud provider(s) by setting their respective environment variables:

  • DigitalOcean: DIGITALOCEAN_TOKEN
  • GCP:
    • GCP_CREDENTIALS_JSON_FILE
    • GCP_PROJECT_ID
    • GCP_SERVICE_ACCOUNT
  • Vultr: VULTR_API_KEY
  • Linode: LINODE_TOKEN
  • AWS: Uses standard AWS environment variables and ~/.aws/credentials

Usage

  1. Create a configuration file or set up the required environment variables
  2. Run the tscloudvpn server:
    tscloudvpn
  3. Access the web interface through your Tailscale/Headscale network on port 80
  4. Use the interface to:
    • View available regions across providers
    • Launch new VPN instances
    • Monitor instance status
    • Manage exit nodes

How It Works

  1. When launching a new instance:

    • Creates an auth key for the new instance
    • Launches instance in the selected cloud provider
    • Waits for instance to become available (up to 1 minute)
    • Monitors instance registration with Tailscale/Headscale
    • Automatically approves the instance as an exit node
  2. The web interface provides:

    • Real-time status of instances
    • Provider and region selection
    • Instance management controls
    • Overview of active nodes

Development

  1. Clone the repository:

    git clone https://github.com/anupcshan/tscloudvpn.git
  2. Install dependencies:

    go mod download
  3. Build the project:

    go build ./cmd/tscloudvpn

License

Copyright (c) 2023, Anup Chenthamarakshan

Licensed under the BSD 3-Clause License. See LICENSE for the full text.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published