Shell_command / ssh: return_code 255

Hi everybody,

I have this shell script below, that I can successfully run when I ssh into my hassos; it will work as intended, in this case, toggling audio playback on a remote linux machine.

However, when I run it through shell_command, I only get Error running command: /config/packages/ "toggle_playback", return code: 255 , What do I need to change in order to make this work?

#!/usr/bin/env bash


ssh -i /root/config/security/hassos $USER@$HOST "/home/me/bin/" "$1"

# vi: ft=bash


  unten_arbeitszimmer_drehknopf_toggle_playback: /config/packages/ "toggle_playback"

EDIT: I also had it like this unten_arbeitszimmer_drehknopf_toggle_playback: '/config/packages/ "toggle_playback"', no difference.

Again, I positively can ssh into my machine and run this; so both the identity file and the code itself must be correct. I ssh into hassos, run this code, and audio playback will toggle on my desktop PC.

I try running this through Home Assistant itself, and I get the error above. I have this in my configuration.yaml

  - "/config/security"

This directory seems to work fine as well; Home Assistant can write to it (via camera.snapshot) and access the files there (via notify.telegram).

These are the contents of that directory; it’s permission seem to be correct as well.


What am I missing? Thank you in advance for your help :slight_smile:

Here is a link you might find helpful

A couple of thoughts:

  • When you run it manually to see if it works, make sure you do so inside the homeassistant container and note that its config path is /config.
  • Follow the guide, as you’ll need an ssh option to deal with the fingerprint reply from the remote host
1 Like

Thank you. I had to add -o UserKnownHostsFile=... to my bash script. Now it works fine, after copying the known_hosts file to my packages directory and pointing to it.