I enabled a restrictive firewall and forgot to allow the non-standard SSH port. The site still worked, but I couldn't reconnect after closing my SSH session. What's a safer way to make changes like this?
Locked myself out after changing firewall rules. How do I avoid doing that again?
Answers
First, check whether your hosting provider offers a web console or another out-of-band connection. That can get you onto the machine without relying on the blocked SSH port, so you can add the missing firewall rule.
For future changes, confirm that console access works before touching the firewall. It's a recovery path, not much use if you discover too late that you can't log in through it.
Reply to this answer
Keep the existing SSH session open and try a new connection after applying the rules. Make sure the new session reaches the right server and port before you close the old one. A working website doesn't tell you SSH is reachable.
Reply to this answer
For remote firewall changes, consider a timed rollback so a lockout doesn't become permanent. One option is a scheduled reboot with the new rules kept nonpersistent until they've been tested.
That only works if rebooting really restores the previous firewall state. Check how your system saves and loads rules, and cancel the scheduled reboot once a fresh connection succeeds.
Reply to this answer
A short checklist helps here: identify the management port, allow it, apply the change, test a fresh connection, and document the recovery route. For repeatable setups, configuration management and a peer-reviewed procedure can catch a missing exception before it reaches the server.
Reply to this answer
I'd also question whether the non-standard port is worth the extra wrinkle. Some admins prefer the standard port because it's easier to remember and document. Others may still choose a different one, but the firewall and recovery procedures need to reflect it either way.
Reply to this answer
Add your answer
Answers are reviewed before publication.
m.461!canvasruler:
Allow the actual SSH port before enabling the restrictive rules, too. Testing a new connection checks that the rule is doing what you expected.