So probably not but its worth noting why this is difficult. Your commands must be non-interactive to work from shell commands and command line sensors and SSH doesn’t want you to use a password in non-interactive sessions for pretty valid reasons:
- It doesn’t want you to store the password in clear-text in a file (which you’ll have to do here)
- It doesn’t want anyone on the system to be able to see the password with a simple
ps
That being said, if you’re comfortable with these risks I have an idea. With some searching I found that the go to tool for this task is one called sshpass
. It accepts the password as a command line argument and uses it to start an SSH session as if it was entered interactively.
Now you can’t install anything in the Home Assistant container since any environment changes like that won’t be persistent. But sshpass is available as an alpine package which means you can add it to the list of alpine packages to install in the SSH & Web Terminal addon. Then what you should be able to do is essentially nest your SSH commands. First go password-less ssh to the addon then use sshpass
to go from there to your remote server.
I want to be clear, I have not tested this as I use password-less SSH everywhere myself. But figured I’d throw it out there as it seems like it should work.
When you say server here, do you mean the remote machine? Cause I think that kind of depends on how it is configured? Like I certainly can, I simply generated pub/priv keys without a passphrase and that’s what I use. Is your server running software that requires a passphrase for private keys?