This Home Assistant service allows you to run SSH commands on remote host. Example main host from Docker container with Hass.
Method 1. HACS custom repo:
HACS > Integrations > 3 dots (upper top corner) > Custom repositories > URL:
AlexxIT/SSHCommand, Category: Integration > Add > wait > SSHCommand > Install
Method 2. Manually copy ssh_command folder from latest release to /config/custom_components folder.
Method 1. GUI:
Configuration > Integrations > Add Integration > SSHCommand
If the integration is not in the list, you need to clear the browser cache.
Method 2. YAML:
ssh_command:
host: 192.168.1.123 # Optional
port: 22 # Optional
username: pi # Optional
password: raspberry # OptionalNew service ssh_command.exec_command:
script:
run_on_host:
alias: Run shell command on host
sequence:
- service: ssh_command.exec_command
data:
host: 192.168.1.123
port: 22
user: pi
pass: raspberry
command: ls -laif you want connect with ssh key, use this
script:
run_on_host:
alias: Run shell command on host
sequence:
- service: ssh_command.exec_command
data:
host: 192.168.1.123
user: pi
ssh_private_key_path: /config/ssh/id_rsa
command: ls -la