SSH into HassOS

@DavidFW1960 Right: I mentioned the port 2222 as a one source of my confusion - since some posts mentioned 2222. I carefully crossed that port in my post not to add to the confusion but failed to mention port 22222. Thanks for adding that.
I clearly got past that USB upload. What I didn’t like about that approach using USB upload is not being able to see what happened. No success/error messaging to my knowledge. If you do everything right - it works. If you mess any single step you are in the dark.
That was the message I was trying to convey: One can verify the key got uploaded (once he knows where it goes) and there is also a way around that USB path. Would have been faster for me than looking for an available USB stick, renaming etc. Noticed some people were asking exactly this question. Thanks.

Restart is not needed. I did this a dozen times yesterday using the same usb config stick and a pi4 (yes, I did a fresh install a dozen times :crazy_face:).

It worked every time.

How did you copy the key from puttygen?

Piggybackign on @mvana suggestion, for me the easiest way was the below: [I didn’t go the USB route because I don’t have an unused usb handy and below is more straight forward imo]

I accessed the HassOS through my proxmox console by using “login” command. Then all I did was to create /root/.ssh/authorized_keys file and pasted my public key. That’s it.

I had to reboot the HassOS to get the SSH to work.
Now I can access the host using “ssh [email protected] -p 22222” and then entering “login” command.

So folks…i am trying to help a fellow maker trying to get his setup running on HA.

Having copied/imported/setup the authorized_keys file on HASSOS you’ll see that i need to run “login” to get to an SSH prompt. Please note that i have applied all the available OS patches, updates.

pi@SmartiPi1:~ $ ssh [email protected] -p 22222
 _    _                                         _     _              _
| |  | |                          /\           (_)   | |            | |
| |__| | ___  _ __ ___   ___     /  \   ___ ___ _ ___| |_ __ _ _ __ | |_
|  __  |/ _ \| '_ ` _ \ / _ \   / /\ \ / __/ __| / __| __/ _` | '_ \| __|
| |  | | (_) | | | | | |  __/  / ____ \\__ \__ \ \__ \ || (_| | | | | |_
|_|  |_|\___/|_| |_| |_|\___| /_/    \_\___/___/_|___/\__\__,_|_| |_|\__|

Welcome on Home Assistant command line.

For more details use 'help' and 'exit' to close.
If you need access to host system use 'login'.

ha > ls -la
Error: unknown command "ls" for "ha"

Did you mean this?
        cli
        dns
        os

Run 'ha --help' for usage.
FATA[0000] Error while executing rootCmd: unknown command "ls" for "ha"

Did you mean this?
        cli
        dns
        os

ha > login
# ls -la
drwx------    4 root     root            42 Apr 16 00:45 .
drwxr-xr-x   13 root     root           210 Apr 16 02:15 ..
drwxr-xr-x    2 root     root          1024 Dec 21  2018 .docker
drwxr-xr-x    2 root     root          1024 Jun  6 22:15 .ssh
#

@tangowhisky37 I think you are doing fine. I don’t even see a question there(?). The “prompt” you are referring to is shell (ash) prompt while SSH is a protocol you are using to communicate with your system.
I see you have .ssh directory there as well. Assuming you have the “authorized_keys” file in place and it contains one or more public keys you may be establishing connection using the rsa key pair instead of password authentication. Please note the access permissions for the directory .ssh (700) and authorized_keys (500). sshd and especially vsftpd may be rejecting keys which are writable by others than owner. (My recent painful experience on CentOS :wink: ).

# pwd
/root/.ssh
# ls -lart
drwx------    4 root     root            42 Apr 15 14:25 ..
drwx------    2 root     root          1024 May 16 02:55 .
-rw-------    1 root     root           800 May 16 03:54 authorized_keys

Hey all,
not sure what im doing wrong.
HassOS 5.0 on rpi4

i keep getting this error: “no support auth message”

Steps taken;

formatted a 8gb USB stick, on my win10 machine to be NTFS

used putt key gen to create a new key

i then copied all the data from the public key (made sure to select all and copy)

opened Notepad++
pasted the values there
started with: ssh-rsa AAAAB3N
ended with: W517QuT1K7Q== rsa-key-20200727

set encoding to be ANSI
image

set edit EOL to be unix

saved the file as “authorised keys”

i then ejected the disk from widows
plugged into my RPI

went to supervisor and did “import from USB”

hw shows as the following:

opened putty
went to my ip and connected
image

approved the new connection certificate

then i went in as root and get this error

Did you ever get this sorted. I am going through this pain right now

EDIT: I just sorted it. Using info from here: https://www.configserverfirewall.com/windows-10/putty-server-refused-our-key/

I did FILE>>LOAD PRIVATE KEY

This generated the public key again. I then pasted it into notepad++ after having set the new document properties (SETTINGS>>PREFERENCES>>NEW DOCUMENT) to ANSI and UNIX/OSX

The difference to previous is the key was one long line now. I couldn’t even scroll to the end of it but it was all there. I uploaded this and it worked. Tedious!

1 Like

thanks for the info!

i ended up plugging in a screen and keyboard to get to it

1 Like

I had the same problem.
I am going to summarize what helped because it is a mix of everything stated here. It might be a documentation overkill but I hope I can help anyone with this.
What did the trick was following (With Windows):

Be sure to have notepad++ installed
change the preferences to following:

format your USB-Drive to FAT and call it CONFIG -> NTFS did NOT work for me even though the “official dev” instruction says it!
grafik

1 . Generate public + private key with puttygen and save them somewhere safe
grafik

  1. in Puttygen: File -> Load Private key

grafik

3.Highlight the Public key that was created in the text box and copy it to the clipboard.

grafik

  1. open notepad++ and paste it.

  2. Be sure that Encoding is ANSI and ELO by default

grafik

  1. in Notepad go to file -> Save as and change the filetype to All types and change the filename to authorized_keys
    Otherwise notepad++ will save it as authorized keys.txt

grafik

7.safely remove the USB drive from your PC and put it into your Home assistant machine.
Open your Home assistant through the browser and go to Supervisor - System -> import from USB
grafik

  1. open Putty
    Type in the Hostname and Port 22222
    Select the private key we generated before and open.

grafik

10 Likes

Thanks for this guideline !!!

Now I came across this and I have to admit that it is a perfect documentation. This is what the documentation should look like.

1 Like

Is there any other way to put the file to the server (SSH addon is installed)?

If you have the SSH add-on installed and working, you should also be able to use your favorite SFTP utility to copy files to the /config (or other) share. The SAMBA add-on also works.

I also had to edit my private key and change the end of line from the windows default to (LF). You may want to edit your detailed directions to add this.

Strange. I was able to ssh into the host using ssh [email protected] -p 22222 but when I logged out using exit and tried to do exactly the same again I got

Error response from daemon: stat /mnt/data/docker/overlay2/f65e25c6430b7bc1be3d5fc90452a1b359f4ff2a88933ad9db4b6c2840ac21fa: no such file or directory

Is there a way to connect directly to ash shell?
With old ResinOS I was able to use WinSCP to browse filesystem and edit file within addon’s containers. Now I was able to connect to 22222 with putty but I need to issue a “login” command before gain access to ash shell…
WinSCP connections fails because don’t recognize command interpreter

image

I can’t get this to work. I have followed this guide to the letter, but I only get connection refused.
I cannot for the life of me understand what I’m doing wrong.

The logs doesn’t tell much either.
I see this, but that’s it:

21-03-03 09:35:10 INFO (MainThread) [supervisor.hardware.monitor] Detecting HardwareAction.ADD usb hardware /dev/bus/usb/001/011
21-03-03 09:35:26 INFO (MainThread) [supervisor.hassos] Synchronizing configuration from USB with Home Assistant Operating System.
21-03-03 09:35:26 INFO (MainThread) [supervisor.host.services] Restarting local service hassos-config.service

I can’t get it to work. authorized_keys file is there, transfered it with WinSCP to root folder and then used mv command to move it to .ssh (via Terminal SSH addon). Putty always returns Connection Refused error. Import from USB button doesn’t seem to do anything.

2 Likes

I do this but show me in putty this:
Unable to load private key file “C:\Users\Piotrek\Desktop\key_private.ppk” (PuTTY key format too new)

Anybody can help…