Home Assistant Community Add-on: SSH & Web Terminal

try using
to: off
instead, all lowercase

Tried it with an error:

2021-03-02 15:06:44 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: expected str for dictionary value @ data['to']. Got None. (See ?, line ?).

Either ’ ’ or " " seem to be required.

Sorry, should be
to: ‘off’

In a pure python hass core, I am pretty sure you have already SSH enabled. So you just need to setup the WebTerminal aka ttyd and add to home assistant as a new panel iframe

This is how this automation works.

alias: UPS
description: ''
trigger:
  - platform: state
    entity_id: sensor.ippon650_beeper_status
    to: enabled
condition: []
action:
  - service: hassio.addon_stdin
    data:
      addon: a0d7b954_ssh
      input: sh /config/nas/beeperoff.sh
mode: single

Code beeperoff.sh

sudo docker exec addon_a0d7b954_nut upscmd -u admin -p *** [email protected] beeper.toggle disabled
1 Like

Dude, that is awesome! It is working well now. So much more straight forward than sshpass ever was.

Thanks

Final automation:

- id: drups beeper off
  alias: "DRUPS beeper off"
  trigger:
    platform: state
    entity_id: input_boolean.drups_beeper
    to: 'off'
  action:
    service: hassio.addon_stdin
    data:
      addon: a0d7b954_ssh
      input: sh /config/boff.sh

Final shell script

sudo docker exec addon_a0d7b954_nut upscmd -u admin -p xxxx [email protected] beeper.disable

Hi, i have a problem with ha core, web gui not working but ssh works, and i try to work with docker but have a message: that to work with docker i need to Turn off Protection Mode from Web gui. but i han’t gui now, can turn off it from terminal? i have hassio os on rpi4. tnx

Is there any way to get the execution results of a script back into HA?
Have an HA-automation for scheduled backups. One action of this automation is calling a Shell-Script in the ssh&webterminal addon.

I would like to somehow report on the success/failure of the execution in HA.

I use MQTT to get info back from a shell script and then an MQTT sensor.

Thanks for the suggestion but I’m not using MQTT.
Does anybody see another way?

You can publish to a sensor directly using a long lived access token and rest

This sounds interesting. I guess I’ll have to dig into this a little.

If you look at the Aussie Broadband script on my Github you can see an example of how to write to a sensor directly. When you restart HA you might end up with an unknown state till it populates it… MQTT will write a retained message so it won’t do that but its a minor issue.

perfect solution for mac users

Is there an example how to use the init_commands to customize files?

I really want to have a custom .vimrc file so I don’t have to remake it every time…but there seems little to no documentation about how to use it.

This doesn’t seem to work, and I don’t know why or where it might tell errors.

init_commands:
  - ln -s /config/.vimrc /root/.vimrc

The symlink doesn’t appear on restarting the addon and logging in.

Any ideas on how to copy output to the clipboard? In normal bash you just highlight it but in zsh it does nothing and unhighlights as soon as you release the mouse. There also seems to be zero online help for doing this.

Everytime I update HA from the terminal now it works perfectly however there is an obscure error returned:

Post "http://supervisor/core/update": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Any ideas? Only does this with the latest update to the addon.

This is awesome. What service should I call to do this?

I just installed Home Assistant OS on Raspberry Pi for testing purpose.
Have been using HA in Docker on RPi since last year.
Now I am trying to establish SSH access to HA.
Installed this addon.
But cannot establish a connection neither with Putty (“connection refused”) nor with web access (“502: Bad Gateway”).
Can anyone teach me how to do it?

Log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] permissions: applying... 
[fix-attrs.d] permissions: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: SSH & Web Terminal
 SSH & Web Terminal access to your Home Assistant instance
-----------------------------------------------------------
 Add-on version: 8.2.2

config:

ssh:
  username: hassio
  password: ''
  authorized_keys: []
  sftp: false
  compatibility_mode: false
  allow_agent_forwarding: false
  allow_remote_port_forwarding: false
  allow_tcp_forwarding: false
zsh: true
share_sessions: false
packages: []
init_commands: []
1 Like

I want to run a automation in this add-on but for some reason sent commands eare not working.

This is mi automation:

alias: Test automation ssh addon
description: test
# any valid trigger, I will be executing it manually for test.
trigger:
  - platform: template
    value_template: '{{ states("sensor.time") == "03:00" }}'
condition: []
action:
  - service: hassio.addon_stdin
    data:
      addon: core_ssh
      input: sh /config/command-scripts/test_script.sh
mode: single

and inside test_script.sh:

#!/bin/bash

# change directory
cd config

# print data to file
ls -a > test1.txt

# close
exit

But it is not working and I don’t see any error in my logs.
I’m running home assistant core.

Can someone help me with this?

this is all that is needed:

authorized_keys: []
apks: []
password: password
server:
  tcp_forwarding: false

and configure the port:


or any other port you want… pick save and you’re good to go?

different versions though?