Secure SSH Without Exposing Public Port 22
SSH is the primary administration entry point for cloud servers, development VMs, and home labs—and public TCP port 22 is simultaneously one of the most relentlessly scanned attack surfaces on the internet. Even with key-based authentication, leaving port 22 publicly reachable exposes sshd to automated brute-force noise, zero-day exploits, and brittle IP allowlists that break whenever your home or mobile IP changes.
Larktun moves SSH completely off the public internet. Your web services (80/443) can remain public when needed, while SSH becomes reachable only from authenticated devices inside your private Larktun tenant under explicit ACL rules.
Why Public Port 22 and Static IP Allowlists Fall Short
- Continuous automated scanning: Public cloud IPs receive thousands of credential-stuffing and protocol-probing attempts daily.
- Dynamic home and mobile IPs: Residential broadband and 4G/5G connections rotate IPs frequently, forcing constant edits to AWS/Alibaba Cloud/Oracle security groups.
- Fragmented team permissions: Access ends up scattered across cloud security groups, jump hosts, and individual
authorized_keysfiles. - Lingering temporary access: When a contractor finishes a deployment or a teammate switches projects, removing their SSH reachability across dozens of servers is error-prone.
With Larktun, network reachability to port 22 is governed centrally by identity + device + ACL.
Step-by-Step: Lock Down SSH Behind Larktun
Follow this exact order so you never lock yourself out of a remote cloud server:
1. Install and Authenticate Larktun on the Server
SSH into the server once using your current method, install the Linux client (see Install and Log In to Larktun on Linux), and join your tenant with an Auth Key:
curl -fsSL https://download.larktun.com/install.sh | sh
sudo larktun up --login-server=https://hs.larktun.com --auth-key=<Your Auth Key>
Verify the server appears Online on the Nodes page and note its private Larktun IP (for example 100.64.0.15).
2. Add a Least-Privilege Port-22 ACL Rule
In the console's ACLs page, allow only authorized operators or groups to reach port 22 on tagged servers:
{
"groups": {
"group:ops": ["alice@", "bob@"]
},
"tagOwners": {
"tag:cloud-server": ["group:ops"]
},
"acls": [
{
"action": "accept",
"src": ["group:ops"],
"dst": ["tag:cloud-server:22"]
}
]
}
3. Verify Private SSH Before Touching the Public Firewall
From your laptop—or directly from the built-in SSH terminal in the Larktun iOS/Android app (which works without system VPN permission)—open a new SSH session to the private IP while keeping your original terminal open as a safety net:
ssh ubuntu@100.64.0.15
Confirm you can log in cleanly, run commands, and reconnect reliably.
4. Close Public Port 22 in Your Cloud Security Group
Once private SSH over 100.64.0.15 is verified:
- Remove the inbound
0.0.0.0/0 -> TCP 22rule in your cloud provider's security group / firewall (keep your cloud console serial/VNC recovery access available as an emergency fallback). - Optionally restrict
sshdor localufw/firewalldrules so TCP22only accepts connections arriving on the Larktun tunnel interface. - Re-test SSH over
100.64.0.15and confirm public port22times out from the open internet.
Best-Fit Scenarios
- Solo developers: Manage Oracle Cloud, AWS Lightsail, Alibaba Cloud ECS, or home mini PCs securely from any coffee shop or hotel Wi-Fi without updating IP allowlists.
- Engineering teams: Grant or revoke production SSH reachability in seconds by editing one tenant ACL instead of hunting through server firewalls.
- Mobile emergency ops: Use the Larktun iOS or Android app's built-in SSH/SFTP terminal to restart services or inspect logs without enabling a system VPN.
- Controlled AI Agent access: Give AI Agents scoped access only to designated dev/staging hosts and ports rather than broad network exposure (see Secure AI Agent Access).