You need SSH access to a server behind NAT with no inbound ports open. How?
AdvancedScenarioNetworking, SSH and remote access
Answer
Situation read → The server must call out; use a reverse tunnel or an agent.
What I'd do →
- Reverse tunnel from the server to a relay:
autossh -M 0 -N -o ServerAliveInterval=30 -R 2222:localhost:22 [email protected]
Then from the relay: ssh -p 2222 user@localhost.
2. Run it as a systemd service so it restarts.
3. Production-grade: an outbound-only agent (AWS SSM, Teleport, Tailscale).
Why → NAT allows outbound connections; the tunnel carries traffic back in.
Interview tip → Mention locking down the relay with GatewayPorts no so the forwarded port isn't public.
More on Networking, SSH and remote access
A key belonging to a departed engineer may be in `authorized_keys` on 300 servers. How do you rotate SSH keys across the fleet?IntermediateYou need to reach a database on a private subnet from your laptop through a bastion. How?BeginnerYour security team wants SSH hardened on all servers. What changes do you make?BeginnerA new server needs a static IP, gateway and DNS on RHEL 9. How do you configure it persistently?BeginnerYou're changing the network config of a remote server over SSH and could lose access. How do you protect yourself?IntermediateA web server should accept HTTP/HTTPS from anywhere but SSH only from the office. Configure the firewall.Beginner