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

First of all, I am running the “alternative” NAS installation of the official image which is running on Synology VM manager.

It seems there are a lot of changes in recent version of HA compared to older posts here. I noticed there is no longer a “Supervisor” menu on the left hand side, but now hide in configuration. At least the function is there which is fine.

However, I am trying to create a second user, but I can not found the option in “configuration > users” as other old post pointed out. I am already an owner and also advance mode is enabled. there is no sign where this option went.

I also tried to enable SSH to host port 22222 (No, not the usual ssh addon, I need to access the host) as per instruction here Debugging the Home Assistant Operating System | Home Assistant Developer Docs , and it doesn’t work. The connection is always refused.

ssh: connect to host 10.0.1.32 port 22222: Connection refused

I am able to SSH into the container at port 22, but when I type command “login”, it ask for login username and password again, none of the username works. And that’s the whole reason why I tried to add a new user on the beginning of this post.

I wonder if there is any new instruction on how to adding new user and getting SSH access to host? thanks.

“People and Zones”

As you can see there is a Users tab up there.

As for SSH, it’s unclear what you mean by “alternative” installation? Do you mean Supervised? Or are you running Home Assistant OS?

1 Like

I am talking about the image from here

Thanks for the hints on the users tab. Now I just created a new user. However, when I SSH into port 22, and then type “login”, it prompt me this

a0d7b954-ssh login: myusername
Password:
Login incorrect
a0d7b954-ssh login:

I can’t login to host using this method. However, I can do that when I am on the console … Why is that?

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