Enable ufw without locking yourself out
enable ufw without losing ssh | ufw allow ssh then enable | set up ufw firewall safely | ufw | firewall | sshWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
ufw allow 22/tcp && ufw enableAllows the SSH port and then enables ufw after a confirmation prompt. If the default policy is deny incoming, all ports that are not allowed are closed from the outside afterwards. If SSH runs on a different port, exactly that port must be entered, otherwise the server is only reachable through the hosting provider’s console.
Note: Check the prepared rules with ufw show added beforehand and keep a second SSH session open to test access after enabling. On web servers, also allow 80 and 443.
Open question before approval: Auf Plesk-Servern klären, ob ufw überhaupt verwendet werden soll oder ausschließlich die Plesk-Firewall-Erweiterung. Falls ufw: welche Ports (8443, 8447, 80, 443, Mail, FTP) vor dem Aktivieren freizugeben sind.
Also searched as
- enable ufw without losing ssh
- ufw allow ssh then enable
- set up ufw firewall safely