Execute bash script dont find sshpass

Hey!

Looking again for some help:
i’m looking to execute a bash script frome home assistant:

Entity is correctly setted up and working as:
shell_command:
audio_shutdown: ‘bash -c /config/scripts/audio_shutdown.sh’

i’ve installed sshpass with “apk add --update --no-cache sshpass” wich is needed in my script and it’s working when manually executed:

My script looks like this:

#!/bin/bash
log="/config/scripts/logs/Moode_audio.txt"
exec 3>&1 1>${log} 2>&1
sshpass -p "password" ssh -o StrictHostKeyChecking=no pi@moode "sudo service mpd stop"
sshpass -p "password" ssh -o StrictHostKeyChecking=no pi@moode "sudo bash /var/local/www/commandw/restart.sh "poweroff""

but once ran: i get

/config/scripts/audio_shutdown.sh: line 7: sshpass: No such file or directory
/config/scripts/audio_shutdown.sh: line 8: sshpass: No such file or directory

Script is working fine when executed from ssh session.

What am i doing wrong? XD

It looks like you’re probably using the install method previously called Hass.io, now known as Home Assistant. When you ran apk you installed the command in the host not in the container that runs Home Assistant (Core).

You need instead to use SSH keys, without passphrases, and specify those on the command line when you call SSH.

Hello!
my installation is a brand new one on a rapsberry pi 3 - as far as i can tell it looks to rely on docker. Does this still apply?
EDIT: ho, i got it - no other way to do i guess :frowning:

I’m in the same boat here, just moved over to core from hassbain and really need sshpass working from shell commands can someone elaborate on the steps for making this work?

Hey, my install of Home Assistant OS on my raspberry pi is doing the same thing, and I don’t think that uses containers, so not sure why it doesn’t work. Can you elaborate on how to setup the ssh keys?

Have a look here

Yes I chose the OS option meaning it shouldn’t be containerised right? So why doesn’t my SSHPASS commands work in shell_commands?

You are using containers. The only one that doesn’t under the current naming convention (9/2021):

Home Assistant Core: Manual installation using Python virtual environment.

I figured it out. You need to install sshpass in the home assistant docker container.

Not sure why you thought HA OS doesn’t use containers - it shows it clearly in the table I linked.