Tools: How to Run Surfshark on Termux via OpenVPN (No GUI Required) - Complete Guide

Tools: How to Run Surfshark on Termux via OpenVPN (No GUI Required) - Complete Guide

Phase 1: What You Need

Phase 2: Setup in Termux

Step A: Update and Install Required Packages

Step B: Get Your OpenVPN Credentials

Step C: Download a Server Configuration File

Step D: Save Your Login (Power Tip)

Phase 3: Connect to the VPN

Step E: Edit the Config File

Step F: Run the VPN

Phase 4: Verify It’s Working

Why This Setup Works Better

Final Thoughts

Affiliate Disclosure When I first started using Termux for networking tools, I ran into a problem. Most VPN apps on Android look nice, but they don’t work well in the background.

They get killed by battery optimization, or they don’t route traffic from Termux properly. That becomes a problem when you're running scans, scripts, or anything that needs a stable connection. What worked for me was switching to a lightweight setup using OpenVPN directly inside Termux. No GUI. No heavy apps. Just a clean, always-on VPN running in the terminal. In this guide, I’ll show you exactly how to do that using Surfshark. To follow this guide, you’ll need a Surfshark account. I recommend it for this setup because it gives access to manual OpenVPN configuration files, which is exactly what we need for a terminal-based setup. Start by updating your Termux environment. Now install OpenVPN and curl: This gives you everything needed to connect to a VPN server from the terminal. This part is important. Your normal Surfshark login (email and password) will NOT work here. You need special OpenVPN credentials. Here’s how to get them: Keep them safe. You’ll use them in a moment. Next, download a server config file. Surfshark provides .ovpn files for different countries. In Termux, run something like this: You can replace the location depending on the server you want. Tip: Choose a server closer to you for better speed. Typing your username and password every time gets annoying. Instead, create a file to store them. Inside the file, add: This makes sure only you can read the file. Now we need to tell OpenVPN to use your saved credentials. Now everything is ready. If everything is correct, you’ll see logs showing the connection is established. Now let’s confirm your traffic is actually going through the VPN. Open a new Termux session. If it shows a different IP (based on the server you chose), then you’re connected. That means your Termux traffic is now encrypted and routed through Surfshark. After using this for a while, the difference is clear. This is especially useful if you're learning networking, cybersecurity, or just want more privacy while working in Termux. Running a VPN inside Termux might look complicated at first, but once you set it up, it just works. You don’t need to rely on heavy apps anymore. If you’re serious about using Termux for networking or cybersecurity practice, this setup makes a big difference. If you haven’t already, you can get Surfshark here:

Get Surfshark VPN This post may contain affiliate links. If you choose to purchase through them, a small commission may be earned at no extra cost to you. This helps support the content and keep guides like this coming. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to ? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

pkg update && pkg upgrade pkg update && pkg upgrade pkg install openvpn curl pkg install openvpn curl curl -O https://my.surfshark.com/vpn/api/v1/server/configurations/united-states-newyork.prod.surfshark.com_udp.ovpn curl -O https://my.surfshark.com/vpn/api/v1/server/configurations/united-states-newyork.prod.surfshark.com_udp.ovpn nano auth.txt nano auth.txt your_openvpn_username your_openvpn_password your_openvpn_username your_openvpn_password chmod 600 auth.txt chmod 600 auth.txt nano united-states-newyork.prod.surfshark.com_udp.ovpn nano united-states-newyork.prod.surfshark.com_udp.ovpn auth-user-pass auth-user-pass auth-user-pass auth.txt auth-user-pass auth.txt openvpn --config united-states-newyork.prod.surfshark.com_udp.ovpn openvpn --config united-states-newyork.prod.surfshark.com_udp.ovpn curl ifconfig.me curl ifconfig.me - Log in to your Surfshark dashboard - Go to: VPN → Manual Setup → Desktop or Mobile → OpenVPN - Copy your username and password - No random disconnections - Lower RAM usage - Works directly with terminal tools - More control over your connection