Learning how to secure VPS access with Tailscale eliminates one of the biggest attack surfaces on any Linux server: publicly exposed SSH and admin ports. The moment a cloud VPS comes online, automated scanners probe port 22, database ports, and container dashboards around the clock.
By placing your server on a private WireGuard-encrypted Tailscale mesh network and locking down UFW to accept admin traffic only on the tailscale0 interface, your public IP exposes nothing except ports 80 and 443 for live web traffic.
Whether you run self-managed VPS hosting or fully managed VPS hosting with Aveshost, this guide walks through installing Tailscale, locking down UFW without locking yourself out, enabling identity-based Tailscale SSH, and enforcing tag ACLs.
Table of Contents
Why Closing Public Admin Ports Matters on a VPS
What is Tailscale? If you are new to private networking, Tailscale is a modern, zero-configuration mesh VPN built on the fast WireGuard protocol. Unlike traditional VPNs that force you to manage complex server certificates or route all traffic through a single bottleneck, Tailscale creates an encrypted peer-to-peer private network (called a tailnet) between your laptops, phones, and VPS instances. Every device you authorize receives a private 100.x.y.z IP address, letting your devices talk directly over an encrypted tunnel even behind home routers or strict firewalls.
Even with SSH key authentication and Fail2Ban enabled, leaving port 22, PostgreSQL (5432), MySQL (3306), or web admin panels open on your public IP forces your server to process constant brute-force traffic and zero-day vulnerability scans.
With Tailscale, your VPS joins a private overlay network in the 100.64.0.0/10 range (100.x.y.z). Public scanners hitting your server’s public IPv4 or IPv6 address see a closed firewall on every administrative port, while your authenticated devices reach SSH and internal dashboards directly over WireGuard.
| Service / Port | Traditional Public VPS | Tailscale + UFW Lock-Down |
|---|---|---|
| SSH (Port 22) | Exposed to 0.0.0.0/0; constant brute-force bots | Allowed only on tailscale0 (100.x.y.z) |
| Databases (3306 / 5432) | Risky if bound to public IP or Docker 0.0.0.0 | Bound to 127.0.0.1 or tailscale0 only |
| Admin UIs (Portainer / Uptime Kuma) | Requires public reverse proxy + auth hardening | Accessible privately over WireGuard tailnet |
| Public Websites (80 / 443) | Open to visitors via eth0 | Open to visitors via eth0 (unchanged) |

Step 1: Install and Authenticate Tailscale on Your Ubuntu VPS
Connect to your VPS over SSH one last time via its public IP, then install the official Tailscale client using the repository script documented in the Tailscale Linux installation guide.
Run sudo tailscale up (or include --ssh to enable identity-based Tailscale SSH right away) and open the printed login URL in your browser to authorize the VPS in your tailnet. Once connected, run tailscale ip -4 to note your server’s private 100.x.y.z address.
Critical safety rule: Before touching any firewall rules, open a brand-new terminal window on your laptop (with Tailscale running locally) and verify you can log in via ssh [email protected].
# 1. Install Tailscale on Ubuntu VPS
curl -fsSL https://tailscale.com/install.sh | sh
# 2. Authenticate and check your private 100.x IP
sudo tailscale up --ssh
tailscale ip -4
Step 2: Configure UFW to Allow Admin Traffic Only on tailscale0
Once you confirm your SSH session works over the 100.x.y.z Tailscale IP, lock down UFW following the Tailscale Ubuntu firewall guide. Set default policies to deny all incoming traffic, allow incoming traffic on the tailscale0 interface, and keep only public HTTP/HTTPS ports open if the VPS hosts websites.
If you previously ran ufw allow 22 or ufw allow OpenSSH, inspect sudo ufw status numbered and delete those public port 22 rules so SSH is no longer reachable from the public internet.
Remember: if you run Docker containers on the same VPS, Docker writes its own iptables rules that can bypass UFW when ports are bound to 0.0.0.0. Always bind internal admin UIs (such as Portainer, Dokploy, Coolify, or Uptime Kuma) to 127.0.0.1 or your Tailscale IP—see our guide on stopping Docker from exposing unexpected ports with UFW.
# Test SSH over Tailscale FIRST: ssh [email protected]
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow in on tailscale0
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Remove public port 22 rules if present, then enable
sudo ufw status numbered
sudo ufw enable && sudo ufw reload
Step 3: Enable Tailscale SSH and Tag-Based ACLs
To eliminate static SSH key sprawl altogether, enable Tailscale SSH with sudo tailscale set --ssh. Tailscale intercepts SSH connections arriving on tailscale0 and authenticates users through your identity provider (Google, GitHub, Microsoft, or Okta) and WireGuard node keys.
For teams managing multiple servers, assign a server tag such as tag:vps and restrict access in your Tailscale Admin Console Access Controls policy so only devices tagged tag:admin-devices can reach port 22 or internal admin ports. Tailscale ACLs default to deny, meaning any port not explicitly listed in an accept block stays blocked even inside your tailnet.
You can also combine Tailscale with private remote desktop tools—for instance, binding self-hosted management dashboards privately alongside our RustDesk Ubuntu VPS setup or securing API backends from our Ubuntu FastAPI deployment guide.

{
"tagOwners": {
"tag:vps": ["autogroup:admin"],
"tag:admin-devices": ["autogroup:admin"]
},
"acls": [
{
"action": "accept",
"src": ["tag:admin-devices"],
"dst": ["tag:vps:22", "tag:vps:8080", "tag:vps:443"]
}
],
"ssh": [
{
"action": "accept",
"src": ["tag:admin-devices"],
"dst": ["tag:vps"],
"users": ["ubuntu", "root"]
}
]
}
Emergency Console Recovery and Ongoing Maintenance
Closing public port 22 drastically reduces automated attack noise, but always verify you have a working out-of-band recovery path. On Aveshost self-managed VPS hosting and fully managed VPS hosting, your client area provides a browser-based VNC/serial console in case tailscaled ever stops during an OS upgrade.
Keep tailscale updated alongside regular apt upgrade security patches so WireGuard keys, DERP relay connections, and kernel networking stay healthy.
Frequently asked questions
Will I lock myself out of my VPS if I close port 22 in UFW?
Not if you install Tailscale first, verify you can SSH into your VPS via its 100.x.y.z Tailscale IP, and add sudo ufw allow in on tailscale0 before deleting public port 22 rules. You can also use your VPS provider’s web VNC console as an emergency fallback.
Does Tailscale slow down public website traffic on port 80 or 443?
No. Public visitors continue connecting directly to Nginx, Apache, or Caddy over your VPS’s normal public network interface (eth0). Only administrative traffic on 100.x.y.z travels through the tailscale0 WireGuard tunnel.
Why does Docker still expose admin ports even after enabling UFW?
By default, Docker publishes -p 8080:8080 on 0.0.0.0 and inserts iptables rules before UFW’s chains. To keep admin dashboards private to Tailscale, bind them to 127.0.0.1:8080:8080 or your 100.x.y.z:8080:8080 Tailscale IP.
What is the difference between regular SSH over Tailscale and Tailscale SSH?
Regular SSH over Tailscale still uses your server’s sshd daemon and ~/.ssh/authorized_keys file, just routed privately over tailscale0. Tailscale SSH (tailscale set –ssh) replaces static SSH keys with identity-provider authentication and tailnet ACL rules.
Is Tailscale free for securing a personal or small-team VPS?
Yes. Tailscale’s Personal plan supports up to 3 users and 100 devices for free, which easily covers securing personal or small-team VPS instances without public admin ports.