Easy one-liner to enable getting an ssh shell in HAOS core itself (not the container)

Note this is not for “beginners” as this accesses the core HAOS filesystem and could mess things up if you don’t know what you are doing…

Sometimes you really want to have low-level access to the HAOS filesystem and access via the containers is just simply not enough…

The following 1-liner that you can run from an advanced ssh-shell (which itself runs in a docker container) unlocks access to a bare metal HAOS ssh shell on port 22222.

(BOOT_PART=/dev/nvme0n1p1; cat /data/.ssh/authorized_keys | sudo docker exec -i homeassistant bash -c "mkdir -p /mnt/temp && mount $BOOT_PART /mnt/temp && mkdir -p /mnt/temp/CONFIG && cat >| /mnt/temp/CONFIG/authorized_keys && umount /mnt/temp && rmdir /mnt/temp")

Then reboot, e.g.,
ha core stop; reboot

You can then access HAOS bare metal from any remote machine using:

ssh -p 22222 [email protected]

(or whatever the name/ip-address is of your HAOS machine)

Note this uses the same public ssh key that you use to access the container-level SSH shell.
If you don’t use an ssh key (which is highly recommended), then you can substitute cat /data/.ssh/authorized_keys with “echo ‘YOUR_SSH_PUBLIC_KEY’”

NOTE this is for a mini-pc with an nvme drive /dev/nvme0n1.
If you have a standard ssd, you typically would use BOOT_PART=/dev/sda1
On a RPi, you typically would use: BOOT_PART=/dev/mmcblk0p1

Note there is an add-on that does this HassOSConfigurator/HassOsEnableSSH at 4aaf8de629be57655aae318adb81ad5635a37a7a · adamoutler/HassOSConfigurator · GitHub

But that requires:

  • Installing the add-on
  • Manually copying over your public ssh key
  • Rebooting
  • Likely uninstalling the add-on

Hi puterboy,

You have been here a few years, you should be able to pick the right category for your posts. Stuff posted to uncategorized tends to die with no one seeing it.
You might want to add a category.
I suggest

for this one