Secure Remote Access with TailScale + Hardened SSH
This guide walks you through setting up secure remote access using TailScale VPN with MagicDNS for easy hostname access along with steps to harden SSH with key-based login.
STEP 1: Install TailScale
SSH into your server or use its console.
Run the TailScale install script:
curl -fsSL https://tailscale.com/install.sh | shAuthenticate the server with your TailScale account:
sudo tailscale upOpen the provided URL in your browser to log in.
STEP 2: Enable MagicDNS
Log in to your TailScale Admin Console at login.tailscale.com.
Go to "DNS" settings in the menu and enable MagicDNS.
With MagicDNS enabled, you can access your server via a hostname like
server-name.tailnet-name.ts.net.
STEP 3: Harden SSH Access
A. Set Up SSH Key Authentication
On your local machine, generate an SSH key pair (if needed):
ssh-keygen -t rsa -b 4096Copy your public key to the server:
ssh-copy-id user@server-ip
B. Disable Password Authentication
Edit SSH config:
Set:
Restart SSH:
C. Change Default SSH Port (Optional)
In
/etc/ssh/sshd_config, change:Restart SSH:
Update your firewall rules (e.g., UFW):
STEP 4: Install and Configure fail2ban
Install fail2ban:
Create a config file:
Example config:
Restart fail2ban:
STEP 5: SSH Tunnel to Access Server Web UI (Optional)
To securely access a web interface (e.g., Proxmox UI) via SSH:
Then open in your browser:
(Optional) Restrict SSH to TailScale IPs Only
To limit SSH access to only TailScale-connected devices:
Summary Table
TailScale VPN
✅ Yes
MagicDNS
✅ Yes
SSH Key Authentication
✅ Yes
Password Login Disabled
✅ Yes
Custom SSH Port
✅ Yes (2222)
fail2ban Protection
✅ Yes
SSH Tunnel to Web UI
✅ Optional
SSH Access via TailScale IP
✅ Optional
Last updated