If you're like me, you use a VPN every day, or at least now and then. Maybe it's for security on public Wi-Fi. Maybe a service you need is blocked in your country. Or maybe your team needs to reach your company's internal services, and all that traffic should come through one VPN: your own.

To get any of that, most people sign up for a VPN service, paid or free. But how sure are you that they don't log your traffic, sell it to data brokers, or use it against you? A VPN stops your internet provider from seeing where you go. It doesn't make that information disappear. You just hand it to the VPN company instead.

If you want to stay in control of your data, there's another way: host the VPN yourself. But how?

I had a lot of VPS servers, and I kept asking myself whether I could run my own VPN on one of them. That way my traffic would go through a machine I control. The answer was yes. So I started building tunnels by hand with OpenVPN, setting up the server and then each client. It worked, but every time it took a while and needed a fair bit of technical know-how. And whenever I got a new VPS, I had to do the whole thing again.

So I decided to make it as simple as I wanted it to be: one command, simple enough that anyone could set it up. I wrote a script that does all of it for you, and it's open source: ur-vps-ur-vpn.

Set up the server

SSH into your VPS and run:

curl -fsSL https://raw.githubusercontent.com/Henryle-hd/ur-vps-ur-vpn/main/server.sh | sudo bash 

There are no questions. It installs OpenVPN, creates the certificates, opens the firewall, and starts the VPN so it comes back after every reboot. When it finishes, it prints a block of text. Copy it, because that's the login for your first device.

One thing to check: if your provider has a firewall in its web panel (AWS, Oracle Cloud, Google Cloud and Azure all do), allow UDP port 1194 there. The script can't change that one, but it tells you where to look.

It works on Ubuntu, Debian, Rocky, AlmaLinux, Fedora, Arch, Alpine and most distros based on them.

Connect your computer

On macOS or Linux, in Terminal:

curl -fsSL https://raw.githubusercontent.com/Henryle-hd/ur-vps-ur-vpn/main/client.sh | bash 

On Windows, in PowerShell:

irm https://raw.githubusercontent.com/Henryle-hd/ur-vps-ur-vpn/main/client.ps1 | iex 

Paste the block when it asks. The script installs OpenVPN, connects, checks that your traffic really goes through your server, and reconnects by itself after a reboot.

To watch the connection live, run ur-vpn top on your computer. It shows the health of the VPN, latency, speed and how much data has gone through. Press q to quit.

ur-vpn top on a laptop, showing a healthy, connected VPN

Prefer an app on your computer?

If you'd rather not use the command line, you can use an app instead. Run sudo ur-vpn app laptop on the server, copy laptop.ovpn to your computer, and import it:

  • Windows and macOS: install OpenVPN Connect and import the file.
  • Linux: you don't need an app. Open Settings, then Network, then VPN, and choose Import from file.

OpenVPN Connect on a Mac, with the Upload File button marked

Connect your phone

Phones can't run the script, so install the free OpenVPN Connect app. Scan a code with your phone's camera, or use the links: App Store or Google Play.

QR codes for OpenVPN Connect on the App Store and Google Play

Then, on the server, run:

sudo ur-vpn app phone 

This saves a file called phone.ovpn in your home folder on the server. Move it to your phone however you like. In OpenVPN Connect, tap + and upload the file, then connect.

OpenVPN Connect on Android, connected, with the + button marked

Treat that file like a password. Anyone who has it can use your VPN.

Add more devices

Give every device its own login with sudo ur-vpn add NAME. If one gets lost, cut it off with sudo ur-vpn revoke NAME.

Watch it live

To see who's connected, how much traffic is going through and who came and went, run sudo ur-vpn top on the server. Press q to quit.

sudo ur-vpn top on the server, with example devices

There are a few more commands, like start, stop, status, logs and update. The README lists them all.

That's it. If you have a VPS that isn't doing much, give it a job.

github.com/Henryle-hd/ur-vps-ur-vpn

As always, stay kind and patient with each other.