How to Reflash a Ubiquiti UniFi Security Gateway (USG)

Update on 2022/05/27: Uploaded and included link to the ‘usg-4-2-0-shipped.img ‘ on the Archive.org.

A few weeks back we had a power outage at our home. Electricity was restored a few hours later and we all thought nothing of it. Everything turned back on and my home network seemed to function correctly.

About a week later, I logged in to my Ubiquiti Network Manager Controller and saw that my Ubiquiti UniFi Security Gateway (USG) was no longer sending over data to the controller software. I still thought little of this issue, since the USG was still routing and blocking unsolicited traffic.

The following weekend I decided I wanted to restore full USG functionality in the Network Manager Controller software, so I decided to simply reboot the USG. This, unknowingly, was my first mistake. After turning the USG back on, I found that the Network Manager Controller software would not hand out new IP addresses from the DHCP scope. I could only attach to the network with a physical connection and a static IP address self-assigned on the same subnet as the USG. I tried to reboot the device several times, but it was all in vain. I realized the device had a deeper issue.

I performed a factory reset on the USG a few times and the lights indicated that the resets were successful, but my connectivity issues on the LAN were not resolved.

At this point, I began researching online on how to reflash the firmware on the USG device. After putting a process together from several articles, I was able to find a viable solution. I will document the procedure below for future reference.


The first step, which led to several minutes of initial frustration, was figuring out how to get into the device. At first I thought it might pry apart, but I quickly figured out this was not the case.

  1. Remove the rubber pads from the bottom of the USG device, revealing four screws. Remove all four screws.
Screw, top-left
  1. After removing all four screws, the top piece of the unit will lift off, revealing the main board of the USG device.

Note: I had already removed the internal USB drive at the time I took this picture. Pretend it is there.

USG main board with USB drive already removed
  1. Remove the USB drive, containing the potentially corrupted firmware.
The USB drive is a silver and slim
  1. Plug the USB drive into a computer and verify it is actually functional. Sometimes USB drives die. If the drive is at least recognized by the computer, proceed to step 5.
  1. Download the factory-shipped image from Ubiquiti here:
    Ubiquiti: https://dl.ubnt-ut.com/cmb/USG-4_2_0-shipped.img.bz2
    Internet Archive: https://archive.org/details/usg-4-2-0-shipped.img
  1. Use your favorite image flashing utility to write the downloaded firmware onto the USB drive.

Note: I like to use balenaEtcher on macOS ($ brew cask install balenaetcher), but Rufus is a good alternative on Windows (> choco install rufus).
Attention: The firmware writing procedure can take 10+ minutes, so do not get frustrated and remove the drive mid-write.

  1. Once the factory image is flashed onto the USB drive and the image is verified, plug the USB drive back into the USG device. Turn on the device.

Note: The initial boot process can taken several minutes, but the light in the middle of the board will come on once it is running.

USB drive installed and LED light on
  1. Reassemble the USG (and do not forget to reapply the sticky pads).

Note: Do not reattach it to the network yet.

  1. Login to the Ubiquiti Network Manager Controller and forget the old USG.
  1. Plug the USG back into the network and more than likely the Ubiquiti Network Manager Controller will automatically adopt it and reconfigure it.

Note: Make sure to apply all applicable updates to the USG, because the factory image is now out-of-date.


Once all of these steps are complete, you should be on your way to full usage of your USG product once more. I am happy they decided to make their boot medium removable and easily re-writable. If you run into any issues, feel free to drop a line in the comments below and I will see if I can assist.

Related Posts

31 thoughts on “How to Reflash a Ubiquiti UniFi Security Gateway (USG)

  1. D.J. thanks for posting the article, maybe you can help. I have a USG gateway usually connect through Google chrome. I couldn’t even get to the Unifi controller login screen being hardwired to my switch, connected to the gateway of course. Finally I connected the pc to the Gateway. Got the login screen and my credentials don’t work. they are good, but i can’t get in to manage the switches or the wireless access point. closing my house and have to turn over the login to the new owner. Now i’m dead in the water. I do have internet coming out of the WAN1 of the gateway. how can i reset/get control over my own stuff? will a hard reset just remove the switches so I get internet only from the one gateway port? I’m a severe novice. can you help me?
    Thanks.

    1. Mark,
      Quite honestly Iā€™m not sure where to start here, nor do I believe I understand the problem. It sounds like you should reset a lot of the equipment, ensure your credentials are correct, re-adopt the equipment, and start from square-one. Iā€™d also read a lot of the documentation on the Ubiquiti website and check out their forums. People there are great and will help you far quicker than I can on this blog. Check out https://community.ui.com/questions

  2. Thank you for this tutorial. A similar thing happened to me. I can now reflash it for someone else to use, but I am disappointed in the USG, so I replaced it with a Fortinet.

  3. I had 4 of these old units laying around, I was able to recover all of them. Thank you!

  4. Protip: when an older USG stops working, it’s most likely that the original flash drive died.

    Purchase a cheap one from your favorite retailer, follow this guide and you’re back in business. You may have to “shuck” the thumbdrive due to the tight clearances, but it’ll still work just fine.

  5. Would it be possible to create a backup image of the USB stick, as a sort of preventive measure? Is it FAT32 or ext4?

  6. Hmm … thanks for the suggestion but after reflashing my USB (with balenaEtcher), I still just get the flashing Console light. šŸ™

    1. Try to use Rufus to flash the drive.
      https://rufus.ie/en/

      Also, I know it sounds silly, but safely eject the USB, if at all possible. Did balenaEtcher verify when you wrote the image to the thumbdrive and validate it matched?

  7. This fixed my issues

    The other night noticed my usg was running on its secondary wan not the primary wan

    Though it might have been a internet issue

    Left it for a day and still on my secondary wan (4G)

    So rebooted my usg and it failed to boot

    The main states light was not lighting up and getting zero network from it

    So swapped in a spare pfsense

    About to log a rma on it when I noticed it just out side of warranty

    I went bugger i will get a new Unifi router of some kind

    Got a order in for a New Dream Router

    Then stupid me went can I refresh it as it has a thumb drive

    Found this and followed your setups and bang fixed

    Oh well I’m going to still upgrade to the UDR and keep this USG as a backup router

  8. Your post got me over one of my USG, but now the other one is in worst scenario.
    Cant’ get to the USG controller browser under 192.168.1.1 . Can’t access SSH as it can’t get it verified or rejects that it’s with someone else. .The original USB failed so I reloaded a 4.2 which loads and I can get the USG in the Ubiquiti Control IOS, but I’m stuck because I can’t hit the box at 192.168.1.1 or on the internet to be verified.
    Any thoughts of how to get in and reset all parameters as Reset doesn’t really do it..
    MAC TERMINAL MESSAGE —-
    ssh ubnt@192.168.1.1
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
    Someone could be eavesdropping on you right now (man-in-the-middle attack)!
    It is also possible that a host key has just been changed.
    The fingerprint for the RSA key sent by the remote host is
    XXXXX6:axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx4.
    Please contact your system administrator.
    Add correct host key in /Users/xxxxx/.ssh/known_hosts to get rid of this message.
    Offending RSA key in /Users/xxxxxx/.ssh/known_hosts:8
    RSA host key for 192.168.1.1 has changed and you have requested strict checking.
    Host key verification failed.

  9. Hi, thanks very much for this guide. I have a USG with a bad power supply and corrupted USB stick and I’m almost all the way to getting it back. Here’s the problem I still have to solve: After putting the 4.2 image on the new USB stick and using a replacement power supply to boot the USG, I can see via putty that the device doesn’t fully boot. Only when I enter the “reset” command at the prompt does the USG fully boot to where I can log in with ubnt/ubnt. Seems like it will be fine until a power cycle, then I’m stuck again until I enter “reset” via putty. I got some feedback in the Ubiquiti community that the USB isn’t coming up fast enough. I’m cross-checking here to see if you agree and if you have any further advice. I don’t know what I can do about that. Do I just have to try another new USB stick? BTW, I bought a cheap 8GB SamData USB2.0 stick as the replacement. Someone in the community also wondered if it’s possible to add a delay i the USG to give the bootloader more time. Any thoughts on that? Thanks again for what you’ve done here, I’m very happy to know that I’m probably getting my USG back again!

    1. First off, thank you for leaving a comment. I apologize it took me so long to see this and get back to you. I’m glad this article was able to help you!

      On this one, I would have to agree with the community. If you are not re-flashing the USB drive that came with the device originally, it might be that the new USB drive you mentioned in the comment is too slow.

      I know it’s not a cheap option, but I would try spending a little bit more money and getting a decently rated USB 3.0 drive. Smaller ones can be had for a reasonable price. I would purchase from a reputable brand, like Samsung or SanDisk.

      The only reason I say this is that I’ve had many cheap, slow USB drives fail to fully write or read when using them for Linux ISO images before. After that lesson, I’ve always used good USB drives. You can look up speed reviews on certain drives you’re considering. I frequently do this because even the name brands can manufacture slow, terrible USB sticks on the cheap. I’ve had my share of SanDisk sticks that took ages to write to, but the read speeds were okay.

Leave a Reply

Your email address will not be published. Required fields are marked *