Getting SSH to work on Home Assistant host via port 22222 on Synology VM (resolved)

Well there are a number of issues here.

  1. Is that you DO NOT type login in to SSH. As soon as you connect it asks you for your username and password. If you are are typing login, then you are telling ssh that your username is “login”
  2. The ssh addon is a docker container (like all addons) - I do not know if the addon has any access to the users system in Home Assistant. Even if it does though, what are you trying to achieve? Please be aware that the ssh addon does not provide any access to the rest of Home Assistant - you really only get access to the /config folder.

It seems like I can get into the host by typing “login” on console, but not via SSH.

Basically, I want to access to the host via SSH session, so that I can have a better SSH client instead of using the console via a webpage. I wonder if there is any method? I saw older post asking same questions, but it seems there is no answer.

Again, this is going to depend very much on HOW you installed Home Assistant. You said it was an “alternative” install, but it’s not clear what that means. Is it running the Home Assistant OS, or is it Home Assistant Supervised running on top of something like Debian?

The install is done using this image from this link below

It’s just a image that will run under VM manager in Synology. It’s running Home Assistant OS and Assistant supervised running in a docker inside the Home Assistant OS.

OK now we are getting somewhere. It is NOT Home Assistant OS, it is Docker only. You can get inside the docker container the same way you get in to any docker container, but it’s not a full OS, it’s only what is required for Home Assistant to run.

In a terminal on your NAS, you type docker ps find the name of the Home Assistant image, it’s probably homeassistant

In a terminal on your NAS you type docker exec homeassistant -ti bash and then will start a bash shell inside the docker container and drop you in to it. That’s the best you can hope for. (Replace homeassistant with whatever the name the docker ps command returns)

It’s not running in a docker. It’s running in a VM. So, it’s a full Home Assistant OS because I need to assign how many ram, how many CPU, allocated disk space…etc for this image to run.

I eventually managed to SSH into the port 22222 on host.

For the record, this is what I did

  1. Use a USB drive formatted with FAT, ext4, or NTFS and name it CONFIG (case sensitive)

  2. Create an authorized_keys file (no extension) containing your public key, and place it in the root of the USB drive. File needs to be ANSI encoded (not UTF-8) and must have Unix line ends (LF), not Windows (CR LF). See Generating SSH Keys section below if you need help generating keys.

  3. Plug the USB into the host machine (for my case it’s a synology 218+)

  4. On the web interface of Synology, inside VM manager, edit the home assist VM, edit the VM machine, and mount the USB stick in the “other” tab.

  5. Go to the home assistant web site, in supervisor page under system tab, there is 3 dot under the Host machine section. Click on that 3 dots and choose import USB.

  6. The instruction page Debugging the Home Assistant Operating System | Home Assistant Developer Docs said it should now be able to use " ssh root@your_synology_ip -p 22222 " and get into host. It did NOT work for me. I tried to manually copy the SSH public key into /root/.ssh/authorized_keys on the host via Console, but it turns out the OS is mounted in READ ONLY mode.

  7. I reboot the VM and keep the USB inside the synology, the /root magically give me write access on /root. I don’t know why, but it just did.

  8. scp myuser@my_other_machine:authorized_keys /root/.ssh/authorized_keys

  9. Go to the home assistant web site, in supervisor page under system tab, there is 3 dot under the Host machine section. Click on that 3 dots and choose import USB once again. Still won’t let me SSH into port 22222.

  10. Reboot the VM once again and I can finally run ssh root@your_synology_ip -p 22222 and get into the host

The hardest part is to get the stupid READ ONLY mode become RW mode. For whatever reason, keeping the USB in the machine did the trick for me. I guess that USB named “CONFIG” has something do with the mounting of /root with write access

Sigh. Why not just say that then?
It’s VERY clear on the page you linked me to - there is a section dedicated to the Synology NAS ( Alternative - Home Assistant ) whereas you appear to have ignored all that and just installed a standard virtual machine, and had we known that we could have reached the solution a lot faster. Yes you have mentioned VM a few times, but you have also been trying to type login to SSH, so it’s not obvious how much computing experience you have.

The reason I am not installing the docker version because the docker version do not have the supervised process running. So that means you can’t even install HACS on that. That’s why I said at the very beginning, I am running that on a VM.

So, I am not ignoring that because I have already tried that and it didn’t work. The docker version wouldn’t let you do anything that need supervised access. In order to have a full version of HA with a proper running supervised instance and a working os-agent running on host, you have to run in VM.

Any idea for this recent version of HA, where “import from USB” does not exist anymore? :frowning:

@PickOne I also noticed that the “Import from USB” option doesn’t exist anymore. There is a documentation issue reported. I also couldn’t find a way to accomplish it via the ha CLI tool either and resorted manually mounting the USB stick on my RPi3 with a monitor and keyboard attached. Once I did this and copied the authorized_keys file onto my device and rebooted(take note you have to reboot,as it’s a system startup check that looks for the authorized_keys file present and enables the direct system SSH over port 22222) then I was able to SSH on port 22222.

Uuu, tell me more, tell me more :smiley:
So, first, I need to make that authorized_keys file into a USB stick with a public key, as far as I know. A key which can be generated with putty and so on…
Than, I put the stick into the device, I add a keyboard, mouse and a monitor, after this… I just reboot the device and everything will be completely done? I don’t need to do anything else?

@PickOne the instructions say that if you name the USB stick CONFIG it should copy that authorized_keys file over but I had to manually mount my USB key and copy it over. That was why I had to have a keyboard & monitor on my RPi.

Can you please explain me how to do it manually? I mean… Where I shuld copy that file, more exactly?

@PickOne that file should be copied into /root/.ssh/. Once it’s there reboot your system and then SSH to the host should be available.

1 Like

I have done it in other way. I just connected with putty to my home assistant, on port 22. Then I added the usb stick to my device, after this, I wrote “ha os import” which is the command to import from usb (the one which is not on UI anymore). After this, I restarted HA, then I connected to port 22222, with putty and the private key,
Now, how can I mount sda1 permanently? to have it even after restart? :smiley:

I tried mount /dev/sda1 /media/hp-drive inside the addon_core_samba container, but I always get “Permission Denied”

2 Likes

@PickOne I was going to mention that with the keyboard attached you need to hit CTRL-ALT-F2 to get another session. However, from that ha CLI screen I’m guessing you could have executed the ha os import command as well. That was the command I was having a hard time figuring out. Nice work!

1 Like

Thanks :smiley:

Do you or anybody else, have an idea about this error? I am trying to mount sda1 to a folder, inside any container, and I get “Permission Denied”. Or if I try to create a directory, I get something about Read-Only… :frowning:

@PickOne the HA OS platform mounts most things in the system as read-only, which is why you get the Permission Denied errors. I was able to mount my USB stick by creating a directory in the /root/.ssh directory since that directory is writable. I believe most things are writable in the /mnt/data directory.

Seems that now I can create folders, but I can’t mount. Whatever directory I use to mount, I get Permission Denied :frowning: I will still try to find a way