I made a custom integration to connect devices like Linux servers, Raspberry Pi’s, Windows PC’s, etc. to Home Assistant via SSH.
It works in a similar way as the official Command Line integration but brings some additional features like:
- SSH authentication with username/password or key file.
- Multiple devices can be connected at the same time.
- All commands and settings can be configured from the UI.
- Multiple sensors can get their value from the same command.
- Dynamic sensors can automatically add/remove entities.
- Sensors can be updated manually by calling a service.
- Devices can be turned on by Wake on LAN.
Default commands are available for Linux and Windows. If you select them in the device setup, some entities will be created automatically:
From HACS: Add
https://github.com/zhbjsh/homeassistant-ssh as custom repository and look for the SSH integration.
From Github: Download the latest release and copy the
custom_components/ssh folder from the zip file to
config/custom_components/ on your Home Assistant installation.
You can find all the details in the link below. If you have any questions, dont hesitate to ask!
Please let me know if anything is not working as it should or if you have any ideas or suggestions for improvements. This is my first integration for Home Assistant, so I’m happy about any kind of feedback!
Seem promising, but it’s stuck on “Please wait, starting configuration wizard for ssh” when I’m adding integration. Any advice how to increase log level? Default log viewer is empty
Hi @p1ne, usually it takes a couple seconds to install the dependencies when you open the integration for the first time (depending on your internet connection).
If it takes too long, you could try to set the default log level to debug by adding the following to
configuration.yaml (don’t forget to change it back later):
Then try to add the SSH integration again and (after waiting for some time) search for
ssh-terminal-manager in the log file. For me it looks like this, maybe yours will show some additional information.
INFO (SyncWorker_2) [homeassistant.util.package] Attempting install of ssh-terminal-manager == 0.9.2
DEBUG (SyncWorker_2) [homeassistant.util.package] Running pip command: args=['/usr/local/bin/python3', '-m', 'pip', 'install', '--quiet', 'ssh-terminal-manager == 0.9.2', '--timeout', '60', '--no-cache-dir', '--upgrade', '--constraint', '/usr/src/homeassistant/homeassistant/package_constraints.txt', '--find-links', 'https://wheels.home-assistant.io/musllinux/', '--prefer-binary']
Let me know if you can make it work! If not, please send me some information about your system (OS, Home Assistant version, Python version, etc.) and how you installed the integration (HACS or manually).
instead. But seems that reboot helped - now it works like a charm. Thank you for awesome plugin!
Nice, was missing such a integration. Managed to sort it by complex command line and certificates but love simplicity. Will try tomorrow!
Great, thanks for trying it out, let me know what you think about it!
I’ve just tried it and it tells me host is offline, hostname / ip doesn’t matter. Must be missing something.
Hi! Could you test if the host replies to ping from the terminal?
Yeh, that’s working as expected:
Ok, in that case maybe you could set the log level to debug and check if there is any message like “Ping request failed”, that could give us some clue…
2023-07-28 16:33:49.042 DEBUG (MainThread) [custom_components.ssh.config_flow] 192.168.21.9: Ping request failed (Root privileges are required to create the socket)
Is the error i’m getting.
Thanks, I will take a look into this problem on the weekend!
Let me know if you need me anything to do or need more information
@mhoogenbosch I released a new version, let me know if it fixes the problem!
Nice! Keep me updated if there are any other problems or if you have ideas for improvements.
Just wanted to say thank you for this integration. It made managing all my proxmox vm easier. Just a great time saver.
I released a new version yesterday (v0.9.4) which fixes a couple small bugs and adds some new sensors to display more information about the device:
To use the new sensors, you have to remove your SSH devices from Home Assistant and add them again after installing the new version. If you made any changes to the commands, please copy them to a text file before deleting the device!
For the next release I’m planning to add a feature to automatically backup and update the commands to make this more convenient in the future.
I just updated and readded my hosts. Works great.
Two things however.
I add my hosts with a regular user (mhoogenbosch in my case) they are not root users but are able to sudo. The command, for example /sbin/shutdown -r doesn’t allow regular users to trigger. Adding sudo in front of the command results in a question for the password, so don’t think that’ll work. Any thoughts on this?
the temp sensor of my homeassistant server doesn’t show. It is a Debian 12 installation on which supervised HA is installed. The command you are using for getting the temp sensor is:
echo $(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))
Where the thermal_zone0 doesn’t excist. It is a AMD system with only cooling devices inside thermal folder.
Adapter: PCI adapter
Adapter: PCI adapter
Composite: +36.9°C (low = -273.1°C, high = +81.8°C)
(crit = +84.8°C)
Sensor 1: +36.9°C (low = -273.1°C, high = +65261.8°C)
Sensor 2: +37.9°C (low = -273.1°C, high = +65261.8°C)
Adapter: PCI adapter
Content of the thermal folder:
$ ls /sys/class/thermal
cooling_device0 cooling_device1 cooling_device2 cooling_device3
Hi @mhoogenbosch , thanks for the reply!
I will try a new command for the temperature sensor to make it look at all the files in /sys/class/thermal, probably this week when I have time.
About the sudo problem I need to do some more research, the only solutions I can come up with are not very safe, either you send the password with the command:
echo <PASSWORD> | sudo -S /usr/sbin/shutdown -r now
Or you store it in a text file on the host machine and use it like this:
sudo -S /usr/sbin/shutdown -r now < password.txt
I will let you know if I can figure out a better way…