0

In enabled my pi‘s firewall with ufw enable and rebooted the pi itself. Now I’m not able to login via ssh anymore. Since it’s a headless Raspbian, I can’t connect it to a display either. Is there another way to reach it than setup from scratch?

2
  • Just connect display and keyboard and you should be able to log in...
    – Dirk
    Apr 10 at 13:53
  • What Dirk means (in case it is not clear) is that if it is headless because you do not have a display and keyboard you can use, life is hard. However, if it is "headless" in the sense that you installed the lite version and have never plugged a display in, do not despair: There's a text based console login that runs by default. You may have to boot with the display attached to get it to work.
    – goldilocks
    Apr 10 at 14:23
1

I haven't done the following myself, but I'm fairly confident this will work (it won't hurt)

  • take the SD card out and put it in another computer
  • edit cmdline.txt (careful which editor you use)
  • add init=/boot/fixufw.sh to the end of the line
  • create fixufw.sh file in the boot partition,
#!/bin/sh
ufw disable
shutdown

or even

#!/bin/sh
ufw limit from any to any app SSH
shutdown
  • put the SD card into the pi and boot
  • wait a few moments until the pi has booted and shut down
  • edit the SD card to remove the text you added
  • put the card in the pi and boot
-1

If you don't have physical access to it ... bad news If you have access but you don't have mouse/monitor/keyboard you can always take the microSD out of it, mount root partition, edit ufw config file and done

3
  • "mount root partition" where? Apr 11 at 0:50
  • if you have an access to this microSD you can mount it on any other Linux machine, or, use other microSD card with Linux to boot your raspberry, and, using usb->microSD interface, enter your microSD, and mount it on the raspberry Apr 11 at 21:03
  • 1
    that's the sort of detail you'd want in the answer ... not just "mount it" :p Apr 12 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.