News for hackers. Stuff that matters.
Re:SSH Emergency Access by isatty on Saturday July 04, 2020 @10:10AM (#23732280)
Yep, the most common way I've lost access to machines is by messing up the iptables/ipfw rules. Read a post here about avoiding that by having a timed reset with sleep.
Re:SSH Emergency Access by lazyant on Saturday July 04, 2020 @11:43AM (#23733022)
For people asking: you can create a resetfw.sh script, for iptables:

  #!/bin/bash

  iptables -P INPUT ACCEPT  
  iptables -P FORWARD ACCEPT  
  iptables -P OUTPUT ACCEPT  
  iptables -t nat -F  
  iptables -t mangle -F  
  iptables -F  
  iptables -X
chmod +x resetfw.sh

and add it for ex to /etc/cron.hourly directory

This way you can test your iptables rules and they'll get clear at every hour. Once you check they are OK you can delete this cronjob.

(NOTE: I'm typing from memory, haven't tested this)

Re:SSH Emergency Access by benedikt on Saturday July 04, 2020 @12:33PM (#23733346)
https://manpages.debian.org/stretch/iptables/iptables-apply....

Or use `at` to run `iptables-restore`. Simpler than setting up a cronjob (and if youre doing it manually, cron has a bunch of gotchas that at least bite me in the ass once in a blue moon).

Re:SSH Emergency Access by lazyant on Saturday July 04, 2020 @12:58PM (#23733489)
Yes. Although iirc (it may have changed, haven't looked "recently" the iptable- commands are distro specific, as in not all of them have / had them).
Re:SSH Emergency Access by metiscus on Saturday July 04, 2020 @11:51AM (#23733071)
You might add a daily task to remove that task just in case you forget. That way you avoid lockout but don't end up opening yourself up accidentally.
Re:SSH Emergency Access by taftster on Saturday July 04, 2020 @12:24PM (#23733283)
Or possibly just turn iptables off, in the same cron.hourly.
Re:SSH Emergency Access by lazyant on Saturday July 04, 2020 @01:00PM (#23733495)
Ah yes, that's simpler: systemctl stop iptables. Also need to do systemctl disable iptables just in case, otherwise if the server reboots the iptables service will restart.
Re:SSH Emergency Access by oars on Saturday July 04, 2020 @11:35AM (#23732960)
This has happened to me as well. Where could I read about this method?
Re:SSH Emergency Access by raincom on Saturday July 04, 2020 @12:59PM (#23733493)
Maybe this:

   service network stop && sleep 10 && service network start
Re:SSH Emergency Access by wiredfool on Saturday July 04, 2020 @05:33PM (#23735052)
The worst is: sudo ifdown eth0 && ifup eth0
Re:SSH Emergency Access by leoh on Saturday July 04, 2020 @11:32AM (#23732929)
Link?