Cloud Key (UKC) gen 1 update not working and fix

(Original post: here)

I wanted to document this as I could not find a single place that had the fix. I forgot what version(s) I was on for firmware and OS but they were out of date, and the gui kept prompting for updates but they NEVER would work. When I went on site to do the update it pretty much just was stuck and stupidly I didn’t try the cli until I ultimately had to.

I was able to get into the CK initially so I grabbed a backup which also didn’t work at first. Had to reboot, but there was also some on the sd card. You could grab a settings only or full.

After that I thought hey let’s do a factory reset. Did that and then the unit would NOT adopt via the phone app, and the manual uses the chrome extension which is no longer a thing. At this point I was looking at buying a gen 2, then said f this, and thought it has to be accessible via ip or cli as it is “adoptable” but kept failing.

I found some forum posts and tutorials on how to update via cli. With the factory reset the ssh was back to ubnt/ubnt.

Once ssh’d in I did the firmware update first (v1.1.9)

ubnt-systool fwupdate https://dl.ubnt.com/unifi/cloudkey/firmware/UCK/UCK.mtk7623.v1.1.19.f4a17b0.210204.0232.bin

This took a bit, I assume the gen1 is pretty slow. The OS/console update took around 30min, I thought it was broken…..

once this firmware is done, I forgot if I rebooted, but I probably did. Then SSH’d back in to do the console OS (7.9.5) I see now that 7.5.7? is available for UCK but was not listed when looking at the devices it supported on the page.

Cd /tmp
Wget https://dl.ubnt.com/unifi/7.2.95/unifi_sysvinit_all.deb
Dpkg -i unifi_sysvinit_all.deb

This will take a while but once finished the unit is supposed to reboot itself.

Once it comes back up I was able to hit the device via the ip, https://192.168.1.7:8443/setup and could setup from a laptop on the same wifi/network. I clicked restore from backup which….kinda worked? Uploading the file from the laptop did not do anything but I was not sure if it was sitting uploading and I could just not tell (25mb file)? I Then plugged the sd card back in and rebooted the UCK. Once rebooted I was able to go back in to the setup and click from backup, but it still was not finding any. I said screw it and thought I would setup as new, then restore. I clicked setup as new, it kind of refreshed, I named the new network and then clicked restore and poof the backups from SD were there. I choose the newest one. Clicked restore and this is where it was probably 30-40 min. After almost nuking it again, I waited and it rebooted on its own, came back up with the blue light and was back to it’s old self but with newer console os code. I was able to login and use it again. I still need to update the console OS code but I wanted to document this for anyone with a UCK and similar stuck update issues. I have another gen 1 to update that I’ll have to go onsite for again.

TLDR: do a backup, know your CK SSH (not same as admin), update firmware and console os via cli

resources used:

https://community.ui.com/releases/UniFi-Cloud-Key-Firmware-1-1-13/733dfc55-b61b-483b-afc1-77d7f2c1e032

https://blog.codybunch.com/2017/06/12/Upgrading-the-UBNT-Cloud-Key-by-Hand

Unifi Controller – HTTP Status 404 – Not Found

  1. SSH into the Cloud Key and delete the corrupted journal files at location:
    /usr/lib/unifi/data/db/journal/j._74
  2. Restart the Unify application:
    systemctl restart unifi
  3. This takes a while but the progress can be monitored from another window by:
    tail -f /srv/unifi/logs/server.log



simulate cron running a script

Step 1: I put this line temporarily in the user’s crontab:

* * * * *   /usr/bin/env > /home/username/tmp/cron-env

then took it out once the file was written.

Step 2: Made myself a little run-as-cron bash script containing:

#!/bin/bash
/usr/bin/env -i $(cat /home/username/tmp/cron-env) "$@"

So then, as the user in question, I was able to

run-as-cron /the/problematic/script --with arguments --and parameters

sort processes by swap

(echo "COMM PID SWAP"; for file in /proc/*/status ; do awk '/^Pid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | grep -wv "0 kB" | sort -k 3 -n -r) | column -t | more

then list all processes with:

systemd-cgls

and match the PID.

usg commands

set interfaces openvpn vtun0 config-file /config/user-data/openvpn/my_expressvpn_usa_-_new_york_udp.ovpn

delete interfaces openvpn vtun0
configure
set protocols static table 5 interface-route 0.0.0.0/0 next-hop-interface vti64
set firewall source-validation disable
set firewall modify VPN_Gateway rule 2502 action modify
set firewall modify VPN_Gateway rule 2502 modify table 5
set firewall modify VPN_Gateway rule 2502 source address 192.168.2.0/24
set firewall modify VPN_Gateway rule 2502 protocol all
set interfaces ethernet eth1 vif 2 firewall in modify VPN_Gateway
commit ; exit

root@SecurityGateway# set protocols static table 5 interface-route 0.0.0.0/0 next-hop-interface vtun0
[edit]
root@SecurityGateway# set firewall source-validation disable
[edit]
root@SecurityGateway# set firewall modify VPN_Gateway rule 2502 action modify
[edit]
root@SecurityGateway# set firewall modify VPN_Gateway rule 2502 modify table 5
[edit]
root@SecurityGateway# set firewall modify VPN_Gateway rule 2502 source address 192.168.60.0/24
[edit]
root@SecurityGateway# set firewall modify VPN_Gateway rule 2502 protocol all
[edit]
root@SecurityGateway# set interfaces ethernet eth1 vif 60 firewall in modify VPN_Gateway