Trouble getting debug access to host from Mac

Following instructions on https://developers.home-assistant.io/docs/operating-system/debugging/
which brings me here: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#platform-mac for my Mac.
my guess these instructions are wrong as this create a ed25519 key and I think we need RSA (I could not get the ed25519 file to work). So after tweaking the ssh keygen command to simply ssh-keygen I get a file containing this (part of string replaced with … to shorten):

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCRZ0/g8xemfMVu.........BrPf4HOQeG2TR68zMlNHujbkP7Q+ISdebHlTBABR3KUQ7nR4/K6ie7rBPpaeqOVqJmVlDJ8vE= paul@PaulsMBP

Then cp .ssh/id_rsa.pub /Volumes/CONFIG/authorized_keys to get it to my USB drive, insert into rpi, import from Usb in the system tab and then from my mac ssh still gives me:

ssh [email protected] -p 22222 
ssh: connect to host 192.168.1.x port 22222: Connection refused

Can anybody share what a correct authorized_keys file should look like and maybe instructions how to generate from a mac?

After copying the contents from my pub key file to TextEdit in mac, I could go to Format > Make Plain Text and the when I save I can select Encoding: Western (Windows Latin 1) which seems to be ANSI encoding with unix LF characters. When I import that my ssh command into the host just simply waits with an empty line:

ssh -v [email protected] -p 22222
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/paul/.ssh/config
debug1: /Users/paul/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to homeassistant.local port 22222.
load: 1.51 cmd: ssh 74261 waiting 0.01u 0.01s

It never completes and doesn’t time out either.

So it sounds like the challenge is more around saving an SSH key to HA so you can connect to your Mac? I do the exact same thing, I used this article to help me over the hump and it works great. I didn’t edit the RSA key manually, I just used the shell commands to generate it for me and no issues. Since you generate the key at the same time you perform an SSH it ensures your SSH name/ip/port are all accurate, then saves the keys on both ends.

This might not be what you are looking for but it might help.

Thanks for your input but that is not what i’m looking for. I want shell access to the HA host from my macbook.

I tried this on my Mac and it looks like ssh is never able to resolve homeassistant.local (at least not quickly), possibly because it’s using mDNS to find out which host “has” that address and nothing responds so it keeps waiting.

In your initial post, you posted this:

ssh: connect to host 192.168.1.x port 22222: Connection refused

This means that there’s simply no sshd listening on port 22222 of host 192.168.1.x. That’s unrelated to (invalid) keys.

I tried it with the ip adress of the rpi as well, no difference.

You mean using the IP address also causes ssh to hang, or do you mean you’re getting the “connection refused” again? Like I said, the latter means sshd is not running, at least not on that port. Typically sshd runs on port 22, have you tried that?

I’m not trying to connect to home assistant core (which would run on port 22) but to the host which runs on port 22222 per the documentation linked in the first post. The ssh deamon only accepts incomming connections if the right authorized keys file is presented from an USB stick first. That is what i’m trying to achieve.

No, sshd will accept any incoming connection. It has to because it needs to check if the public key is valid. When it’s not valid, you’ll get a specific message (“Permission denied”).

The message you’re getting, “connection refused” means there is no sshd listening on port 22222.