SSH command for remote execution issues

Ok … I know that this is technically bash commands but I can’t find anything on this at all so I am asking here out of sheer desperation!

Notes:

  • I want to automate a command from HA (which I know how to do)
  • I am using docker so don’t want anything that I can’t fully automate after the docker image is cleared
  • I cannot use shared keys as I am connecting to physical hardware that does not support them
  • The fingerprint changes each time I connect to the remote device

Because of the last two points I am having issues… when I connect I have to do it with a password (which I don’t mind doing through the command line)
…I have tried SSHPass, but don’t know how to get it working … also remember that this is docker so point 2 applies with regard to this.
…also I believe that even with SSHPass I will have to type “yes” to accept the random fingerprint each time I connect…

Surely someone has had this issue before and knows how to do this … why on earth you can’t just go:
ssh -acceptfingerprint yes -p 22 user:pass@hostname ‘command here’
is beyond me!

I think the option you want is StrictHostKeyChecking - see man ssh and Shell Command SSH

Cool … prob solves the fingerprint … but how about passing a password around?

What sort of ssh server doesn’t support key authentication?

You may need to script it with expect.

This is a piece of hardware … it doesn’t use linux commands either

@i00 Do you have any specific error that is being returned when you try the command?

Use the following syntax to get a command.log file in your config folder containing any error output from the shell_command:

ssh user@server 2 >command.log

I have not gotten to the point of calling the command yet … I know it will not work as the calling the command prompts for a password … I need to be able to pass this into the command as plain text that does not seem to be an option :frowning:

Have you tried expect yet?

@i00 have you tried yet installing sshpass into HA docker? You put this into a Dockerfile

FROM homeassistant/home-assistant

# install the required utility
RUN apk --no-cache add sshpass

LABEL description="Home Assistant plus sshpass"

and you reference this from your docker-compose.yaml

services:
  homeassistant:
#    image: homeassistant/home-assistant
    build: 
      context: .
    image: home-assistant:home-assistant-with-sshpass

and build it up using docker-compose up -d --build

Now you can access sshpass with a command_line