šŸ†•[add-on] HassOS SSH port 22222 Configurator

Hi Adam, ok, where?

I use the windows CMD terminal:
image

When I use putty terminal itā€™s even worst:

Ok, now I tried it with a key-pair which I created via Putty-Gen. Now it works with Putty, but not with Windows CMD anymore. Error is "Permission denied (publickey,keyboard-interactive). "
But anyhow canā€™t access port 22222

Iā€™m not sure where your windows public key is located, but you may try to find it or replace your windows keypair with your putty keypair.

Hi @adamoutler, Iā€™m much further after disable protection mode. Port 22222 was found, but still facing a problem with my key:


My public keys are in the same folder regardless on how I created the keys (ssh-keygen or via Putty-Gen). If I understand correct, the private key canā€™t be found in the putty terminal session?

Everything works now from Putty. The problem was, that I canā€™t access port 22222 from inside of the session above.
I need to access port 22222 directly from Putty.
Thanks a lot.

If you can ssh to your normal instance without password, then cat ~/.ssh/authorized_keys and use that key in that Configuration. Then you can ssh the same way.

In the end it is working in my enviroment also, Happy days!! It is also working from putty directly to port 22222.

Thanks for your help and input @adamoutler and @Ruestafari!!

1 Like

I have been trying to get the SHH Port 22222 Configurator working and Iā€™m running into issues. Iā€™m running HassOS in a KVM/libvirt VM under Ubuntu Server. I have tried it a bunch of times but it seems that SSH is never runningā€¦ itā€™s always ā€œconnection refusedā€ when I SSH to port 22222 (so I know itā€™s not a key issue since Iā€™m not even getting to that point). Some notes:

  • I have tried with Protection Mode on and off
  • I have made sure I updated the ssh-key on the Configuration page
  • I have made sure I rebooted multiple times using Supervisor -> System -> Host -> REBOOT HOST
  • I have tried manually running it via the Start button and having ā€œStart on bootā€ enabled
  • On the /config/info URL I show Iā€™m running:
    • Home Assistant 2021.3.4
    • Hass.io -> Host Operating System: Home Assistant OS 5.12

The output on the addon Log tab/screen is:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
nothing to do. I can't find a /dev/sda1, /dev/sdb1, or /dev/mmcblk0p1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

I always seem to get the nothing to do. I can't find a /dev/sda1, /dev/sdb1, or /dev/mmcblk0p1 line.

Anyone have any ideas where itā€™s going wrong? Thanks!

Those block devices probably donā€™t exist in a KVM/libvert environment. Hence the addon does not know where to save the key.

OK, thanks. So does the Port 22222 Configurator not work in KVM/libvirt? Is there any work around?

If I canā€™t get Port 22222 Configurator to work, is there ANY other option other than the ā€œImport from USBā€ option or is that it?

Thanks!

I am not au fait enough with kvm to know for sure.

Using ssh to home assistant container, what does the mount comand return? Use ssh& web terminal addon.

@nickrout Here is what I getā€¦ Thanks!

~ $ mount
overlay on / type overlay (rw,relatime,lowerdir=/mnt/data/docker/overlay2/l/V3MQI5VMTJK63JZQBG4AYYQDEY:/mnt/data/docker/overlay2/l/XZ3BENCKCWTMDOBQMCXLD4QP4G:/mnt/data/docker/overlay2/l/ZZS65CA6HZTC45HQFJU63CKSFC:/mnt/data/docker/overlay2/l/WK3PIECNPUTZFJEYPJIML7IXDA:/mnt/data/docker/overlay2/l/JM6WQLLG3FTK2VXDOHHRA2FCFD:/mnt/data/docker/overlay2/l/XNDID7BZD4HU3NRL3MBF7W2SUO:/mnt/data/docker/overlay2/l/6TCT67HJKBI3LHQDTX7XO2SM5G:/mnt/data/docker/overlay2/l/22BRIONPYBAPJ6XBYO5Q4Q2PFQ:/mnt/data/docker/overlay2/l/PTUEA3JBSDADVPFEGLEVIIJVM5,upperdir=/mnt/data/docker/overlay2/ad5343f58260ff763ee46403f3e942bb2adadb536660121690ecbc75b0cd7a29/diff,workdir=/mnt/data/docker/overlay2/ad5343f58260ff763ee46403f3e942bb2adadb536660121690ecbc75b0cd7a29/work)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (ro,nosuid,nodev,noexec,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (ro,nosuid,nodev,noexec,relatime,xattr,name=systemd)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (ro,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (ro,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (ro,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (ro,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (ro,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/perf_event type cgroup (ro,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/devices type cgroup (ro,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (ro,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/pids type cgroup (ro,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/memory type cgroup (ro,nosuid,nodev,noexec,relatime,memory)
/dev/vda8 on /addons type ext4 (rw,relatime)
/dev/vda8 on /backup type ext4 (rw,relatime)
/dev/vda8 on /media type ext4 (rw,relatime)
/dev/vda8 on /ssl type ext4 (rw,relatime)
devtmpfs on /dev type devtmpfs (ro,relatime,size=1494360k,nr_inodes=373590,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
/dev/vda8 on /data type ext4 (rw,relatime)
/dev/vda8 on /config type ext4 (rw,relatime)
/dev/vda8 on /share type ext4 (rw,relatime)
/dev/vda8 on /run/audio type ext4 (ro,relatime)
/dev/vda8 on /etc/asound.conf type ext4 (ro,relatime)
tmpfs on /run/dbus type tmpfs (ro,size=598524k,nr_inodes=819200,mode=755)
/dev/vda8 on /etc/hosts type ext4 (rw,relatime)
/dev/vda8 on /etc/resolv.conf type ext4 (rw,relatime)
/dev/vda8 on /etc/hostname type ext4 (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)
/dev/vda8 on /etc/pulse/client.conf type ext4 (ro,relatime)
proc on /proc/bus type proc (ro,relatime)
proc on /proc/fs type proc (ro,relatime)
proc on /proc/irq type proc (ro,relatime)
proc on /proc/sys type proc (ro,relatime)
proc on /proc/sysrq-trigger type proc (ro,relatime)
tmpfs on /proc/asound type tmpfs (ro,relatime)
tmpfs on /proc/acpi type tmpfs (ro,relatime)
devtmpfs on /proc/kcore type devtmpfs (ro,relatime,size=1494360k,nr_inodes=373590,mode=755)
devtmpfs on /proc/keys type devtmpfs (ro,relatime,size=1494360k,nr_inodes=373590,mode=755)
devtmpfs on /proc/timer_list type devtmpfs (ro,relatime,size=1494360k,nr_inodes=373590,mode=755)
tmpfs on /proc/scsi type tmpfs (ro,relatime)
tmpfs on /sys/firmware type tmpfs (ro,relatime)

@adamoutler

Same problem on an Intel NUC with an SSD drive, that is not mounted as sda1 sdb1 but like this:

/dev/nvme0n1p8 on /share type ext4 (rw,relatime)
/dev/nvme0n1p8 on /config type ext4 (rw,relatime)
/dev/nvme0n1p8 on /backup type ext4 (rw,relatime)
/dev/nvme0n1p8 on /addons type ext4 (rw,relatime)
/dev/nvme0n1p8 on /data type ext4 (rw,relatime)
/dev/nvme0n1p8 on /ssl type ext4 (rw,relatime)
/dev/nvme0n1p8 on /media type ext4 (rw,relatime)
/dev/nvme0n1p8 on /etc/asound.conf type ext4 (ro,relatime)
/dev/nvme0n1p8 on /run/audio type ext4 (ro,relatime)
/dev/nvme0n1p8 on /etc/hosts type ext4 (rw,relatime)
/dev/nvme0n1p8 on /etc/hostname type ext4 (rw,relatime)
/dev/nvme0n1p8 on /etc/resolv.conf type ext4 (rw,relatime)
/dev/nvme0n1p8 on /etc/pulse/client.conf type ext4 (ro,relatime)
/dev/nvme0n1p8 on /var/log/journal type ext4 (ro,relatime)

These are the partitions:

nvme0n1                                    232.9G KINGSTON SA2000M8250G
ā”œā”€nvme0n1p1                                   32M
ā”œā”€nvme0n1p2                                   24M
ā”œā”€nvme0n1p3              /sbin/docker-init   256M
ā”œā”€nvme0n1p4                                   24M
ā”œā”€nvme0n1p5                                  256M
ā”œā”€nvme0n1p6                                    8M
ā”œā”€nvme0n1p7                                   96M
ā””ā”€nvme0n1p8              /var/log/journal  232.2G

Would be good to have this addon working also in non-standard cases like this. Maybe a configuration option to specify the partition would be a good idea, unless thereā€™s a way to retrieve it automatically.

Thanks for any help on this.

Hi,

I gave this addon a go today but eventually ended up uninstalling it again. Somehow itā€™s not completely removed :frowning:
Now when i want to start Terminal & SSH addon i get the error that Port 22222 is alread in useā€¦
Is there anything i can do to remove the last traces of this addon? I restored a full snapshot from 3 days ago but the problem is still there.

Hello,

Iā€™m having difficulty getting this add-on to work. I have protection mode off, I have rebooted the host multiple times via the supervisor, I have entered in the public key enclosed in quotes, but I still get a connection refused error. Iā€™m using an ODROID-N2+, and this is my information under system health: |Version|core-2021.8.6|
|Installation Type|Home Assistant OS|

This is in my log:

Blockquote
[s6-init] making user provided files available at /var/run/s6/etcā€¦exited 0.
[s6-init] ensuring user provided files have correct permsā€¦exited 0.
[fix-attrs.d] applying ownership & permissions fixesā€¦
[fix-attrs.d] done.
[cont-init.d] executing container initialization scriptsā€¦
[cont-init.d] done.
[services.d] starting services
[services.d] done.
nothing to do. I canā€™t find a /dev/sda1, /dev/sdb1, /dev/mmcblk0p1 or /dev/nvme0n1p1
[cont-finish.d] executing container finish scriptsā€¦
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

I was able to use putty to connect to port 22 using the public/private key so I think that part is working fine.

probably easiest to create a pub/priv key pair on linux, make sure to use rsa i had an issue using ecdsa.

turn off protection mode, add key with addon stopped. start addon. It should say created keys. Then you can login. Hoorah.

I wasnā€™t going to bother with this, i was just consoling in to the hassos vm then running a shell script in /mnt/data to mount cifs to /mnt/data/supervisor/media everytime I did a HASSOS reboot. (rare).
Then I passed through my CPU/GPU for ffmpeg and was blindly typing into a non-responsive console to run said shell scriptā€¦ :rofl:

This addon makes it much cleaner now and only requires one attempt :stuck_out_tongue: thank you very much.

Now if only I could put a command somewhere to run when HASSOS bootsā€¦?

Oh my god. Can someone help me please. I have NO IDEA about keys. I just want to disable IPv6 (which I wish never existed). I have used puttygen to create a key but I simply have no idea which bit to cut and paste. And whats the root@Ha_xxx in the config file? Do I modify that? delete it? Sorry, I know Im a noob but I really wish I didnā€™t have to be a cybersecurity expert just to turn a lightbulb off. Any understanding help appreciated.

I would recommend using WSL to generate the key, and also read up on ssh keys. There are many explanations on the net.

The root@Ha_xxx is part of the key. Once you have generated the key it will be part of the id file

Specifically (in WSL):

ssh-keygen -t rsa -b 4096

The program will prompt you to choose where to put the key files. It will probably be C:\Users\you\.ssh. Once the program finishes cd to that directory and the files will be there. On my system

cd C:\Users\OEM\.ssh
ls

system responds

    Directory: C:\users\oem\.ssh


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        13/09/2021   5:49 PM           3389 id_rsa
-a----        13/09/2021   5:49 PM            746 id_rsa.pub

The file you want is the .pub file.

cat id_rsa.pub

system responds (and I have obfuscated parts of this)

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDohEc+C96Dgn8Kt3691Tvt0Rp6kQ4IhChQ44orbvaPBohWa1WobxhwswlCC7Ws6KaRztyPDcAPVQr4NE+xSFHhrRAE/GzKMNRBrHem3KCUeyLlSDsCq05We5VVwXJ198ffpqSWPAGIL+MV/2m8bRpzJCesD8A3jnuhuxrcyLptgqILiIde6Pzi/uz87qzIyFBNLBn36jjRNDsXsQ6ZrnVM1csg8M11+v/a/udKcwW+vxMgIKXatB/jq0JV6DLp1mJrP6osFLdsCNDJ/iweyfdxhSwfEZ1tm/diR0EkCvhPhFT4j+vY6Jyha50iM6NH7TUR+K8oavVdlFQ2Rk8eONB+R2ekz3vyOUzy5sYgBk/OhDFawl6D6iWDyB5lv/Guiaq62D7biUS7YUlCddhErp55WVoBbjoeAmhFnGxxxxxxxxxxxxxxxBCN1wufLCE6ozs886U9MEdWAt3pBUv4BRYouTIIEW2FMQrSyEqRBCqETftYuFAWZRLOSziHMVESbQ3k5aPzzX4EZFrj0Z/tF+z8cELD30dKTg48zW6/DteNizu3dI0GhjaJOgsA/1Pnf7EuJVm1wfMahWiAP0CkiZ722P0yCb6gYntRUkHI7l6aPaSNMFrYjVwtSuITMJgcthrE0fkq4k0r6Wgkyyf2RLmjovvQ+VBrKW7f7Edi/Q== oem@xxx

Simply copy and paste into the addon.

1 Like