🆕[add-on] HassOS SSH port 22222 Configurator

Which container are you in?

If you are logged in to the OS (which this addon enables) then you can run systemctl.

Inside containers, it frankly depends on how the container is built.

In any event, you are getting off topic in this thread,

Just here to say thank you for making this so simple for that very rare odd occassion that I need to jump into the supervisor.

2 Likes

Running Home assistant OS in VirtualBox over Windows11
Trying to gain root access so I can modify some files in the Zigbee2MQTT addon

ex. commands to be run are:

docker exec -it $(docker ps | grep zigbee2mqtt | cut -d" " -f 1) /bin/sh

vi node_modules/zigbee-herdsman-converters/converters/toZigbee.js

docker restart $(docker ps | grep zigbee2mqtt | cut -d" " -f 1)

I installed the HassOS SSH port 22222 Configurator and it worked as expected
then copied public key in SSH addon

but still couldn’t get ssh access with

ssh 192.168.0.xxx -p22222

(something about public key wrong or keyboard input which is obviously not possible with a VM?)

Next I tried “ssh-keygen” and am getting the same results.

Tried starting from scratch but now am getting this and not sure how to delete existing keys…

image

image

Can you provide some guidance on the best way to get this working ?
just can’t find a complete process for my use case.

Thank you.

You don’t need root access to the operating system to do that.

Edit: moved conversation here / opened pull request.

Thank you for your reply, but can you elaborate?
fyi, this is what I am referring to:

I think I managed to login to root and gain access to the container via
the VirtualBox CLI (it does accepts my login and docker commands)

image

Thank you!

Hi,
I need help to configure the access.
I’m using a Raspberry.
I installed the plugin.
I generated both public in private keys.
I copied the public key into the plugin configuration field using quotation mark “key”.
I tried to connect using Putty and it doesn’t work.
I tried to connect from the Home Assistant shell and it doesn’t work as well (I connected to Home Assistant via ssh on port 22 and I ran ssh ipaddress -p 22222).

This is the log
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[skip] /dev/vda1 does not exist.
[skip] /dev/sda1 does not exist.
[skip] /dev/sdb1 does not exist.
Writing authorized_keys in /dev/mmcblk0p1
[SUCCESS] Key written to /dev/mmcblk0p1.
[skip] /dev/mmcblk1p1 does not exist.
[skip] /dev/nvme0n1p1 does not exist.
[skip] /dev/xvda8 does not exist.
[Done] Configurator complete. Perform a hard power-off now. This configurator only works once and is no longer needed.

From the shell the error is
root@ipaddress: Permission denied (publickey).

What could be the problem?

1 Like

Use ssh -vv to get verbose output.

Thanks, worked for me. Just have a question as a “green” person in topic. After uninstalling, public key is still there? If i lost private key and install this plugin again, perform all steps will work for new keys?

@adamoutler how can i use this to paste a audio file to my asterisk addon container? I can see the container folder but i dont know how i can paste a file inside the folder. :sob:

This has nothing to do with a ui (which is required for a ‘paste’.)

What exactly are you trying to do?

You’ll need to download things.

while this is great, the instuctions are wrong. create the key with putty keygen, I believe nothing else works.

when you copy the public key to the addon, don’t type SSH and do NOT use any quotes “”. Just copy the plain key from putty without line breaks or anything and then it works! took me 3 days.

The GUI must look like this:

Only then the YAML will look like this

It seems such a simple task but I fail on that whatever I do.

I noticed that the addon writes to sda1.
How can I confirm it’s correct?

df points to /dev/sda8. Could it be the reason why it doesn’t work? If so, how to workaround that?

Seems likely

partitions=(
  vda1
  sda1
  sdb1
  mmcblk0p1
  mmcblk1p1
  nvme0n1p1
  xvda8
)

How did you install HAOS?

I did it burning an official image into SSD.
I have the SSD connected to the USB3 port booting from it.

In the meantime, I spotted in Glances, that sda and sda8 are the same devices. But I suppose it doesn’t change anything.

sda is a drive. sda8 is a partition on that drive. They are not the same.

Why an app for doing something documented in the doc ? You just need a usb key.

  1. USB key was not always available
  2. USB key requires additional hardware
  3. USB key doesn’t always work
3 Likes

This is genius, wanted to add this to config.txt for the rpi5:
echo ‘usb_max_current_enable=1’ | tee -a /mnt/boot/config.txt
echo ‘dtparam=sd_cqe=on’ | tee -a /mnt/boot/config.txt
Was fiddling with the usb method but couldn’t crack it, this worked first try.

1 Like

I was happy to find this thread. I’ve been meaning to get ssh access to the host (and this looks like a great opportunity to learn more about my system).

The add-on logs reported the key was written, although I’m unclear if it was written to the correct place. I have an SSD for my data partition.

Writing authorized_keys in /dev/sda1
[SUCCESS] Key written to /dev/sda1.

And I can confirm the correct key was written looking the md5. Here’s on my mac:

bill@whm4pro ~ $ md5sum .ssh/id_rsa.pub
8988aec48b06d953e047c297a556328a  .ssh/id_rsa.pub

And if I connect to the add-on container you can see the correct key was installed.

➜  config docker exec -it 2cd0c3a6ebc6 bash

1f3d020e-hassos-ssh-configurator-addon:/data# md5sum /tmp/sda1/CONFIG/authorized_keys
8988aec48b06d953e047c297a556328a  /tmp/sda1/CONFIG/authorized_keys

After rebooting the host:

bill@whm4pro ~ $ ssh [email protected] -p 22222
[email protected]: Permission denied (publickey).

It’s been a few years since I used Docker regularly, so pretty rusty now. But, a bit surprised can mount the root file system from within a container. Maybe I’m not understanding how protection mode works.

Here’s running parted on sda:

1f3d020e-hassos-ssh-configurator-addon:/data# parted /dev/sda print
Model: SanDisk Extreme SSD (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: pmbr_boot

Number  Start   End     Size    File system  Name              Flags
 1      1049kB  34.6MB  33.6MB  fat16        hassos-boot       msftres
 2      34.6MB  59.8MB  25.2MB               hassos-kernel0
 3      59.8MB  328MB   268MB                hassos-system0
 4      328MB   353MB   25.2MB               hassos-kernel1
 5      353MB   622MB   268MB                hassos-system1
 6      622MB   630MB   8389kB               hassos-bootstate
 7      630MB   731MB   101MB   ext4         hassos-overlay
 8      731MB   1000GB  999GB   ext4         hassos-data
Here's my /dev from inside the add-on container:
1f3d020e-hassos-ssh-configurator-addon:/tmp/sda1# ls /dev
autofs           input            net              ram8             tty0             tty27            tty45            tty63            vcsa             video11
block            kmsg             null             ram9             tty1             tty28            tty46            tty7             vcsa1            video12
bsg              kvm              port             random           tty10            tty29            tty47            tty8             vcsa2            video13
btrfs-control    log              ppp              rfkill           tty11            tty3             tty48            tty9             vcsa3            video14
bus              loop-control     ptmx             sda              tty12            tty30            tty49            ttyACM0          vcsa4            video15
cachefiles       loop0            pts              sda1             tty13            tty31            tty5             ttyprintk        vcsa5            video16
char             loop1            ram0             sda2             tty14            tty32            tty50            uhid             vcsa6            video18
console          loop2            ram1             sda3             tty15            tty33            tty51            uinput           vcsm-cma         video19
cpu_dma_latency  loop3            ram10            sda4             tty16            tty34            tty52            urandom          vcsu             video20
cuse             loop4            ram11            sda5             tty17            tty35            tty53            v4l              vcsu1            video21
disk             loop5            ram12            sda6             tty18            tty36            tty54            vc-mem           vcsu2            video22
dma_heap         loop6            ram13            sda7             tty19            tty37            tty55            vchiq            vcsu3            video23
dri              loop7            ram14            sda8             tty2             tty38            tty56            vcio             vcsu4            video31
fd               mapper           ram15            serial           tty20            tty39            tty57            vcs              vcsu5            watchdog
full             media0           ram2             shm              tty21            tty4             tty58            vcs1             vcsu6            watchdog0
fuse             media1           ram3             snd              tty22            tty40            tty59            vcs2             vga_arbiter      zero
gpiochip0        media2           ram4             stderr           tty23            tty41            tty6             vcs3             vhci             zram0
gpiochip1        media3           ram5             stdin            tty24            tty42            tty60            vcs4             vhost-net        zram1
gpiomem          mem              ram6             stdout           tty25            tty43            tty61            vcs5             vhost-vsock      zram2
hwrng            mqueue           ram7             tty              tty26            tty44            tty62            vcs6             video10

Should the /CONFIG/authorized_keys file be copied somewhere on boot?

By the way, why doesn’t this work when I just ssh in?

1f3d020e-hassos-ssh-configurator-addon:/tmp/sda1#
exit
➜  config parted /dev/sda print
Error: Error opening /dev/sda: Operation not permitted
Retry/Cancel? c

Thanks.