Closed solderchicken closed 7 months ago
Hi,
I just had a look at your device.db... Your uniqueids are in the f8:99:13:9d:f5:e1:05-93 style. I have found that nothing works right unless you have the 9 octet style unique IDs. Try replacing the "-" with something like :aa:. This is mainly for interfacing with Alexa though.
And you might try giving the absolute pathname of etherwake. And is it installed in your container?
Also I always set Content Type to "text/plain".
Hope these help.
Rob
Thank you. No dice still I'm afraid.
I have removed the Docker version and installed 'normally' using the instructions here https://github.com/bwssytems/ha-bridge
ha-bridge will pass my wakeonlan calls and appears to pass my scripts and ssh code but still nothing happens.
Wakeonlan is working but my calls to invoke a reboot or shutdown over ssh do not work.
I have correctly generated and copied ssh ids to the pc in question and can access via ssh without password.
Running the scripts in terminal works perfectly, as does just running the code in terminal.
Doing exactly the same on a Raspberry Pi works, but I really would like to consolidate ha-bridge onto my Ubuntu machine.
Is it something to do with java? And/or permissions?
user@ubuntu-server:~$ java -version
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Ubuntu-0ubuntu222.04.1, mixed mode, sharing)
My scripts are like this
#!/bin/bash
wakeonlan [macaddress]
exit 0
#!/bin/bash
ssh root@192.168.1.152 reboot now &> /dev/null &
exit 0
All bridge items are set to 'ExecuteScript/Program' In the 'Call' section for ha-bridge, I have tried every format I can think of... (see below) I have tried every option for 'Content Type'. On the RPi I always left this blank and it works fine.
e.g - (all these execute with out error in ha-bridge but do not do anything) All these execute in Terminal and work perfectly.
ssh root@192.168.1.152 sudo reboot now
/home/user/Desktop/reboot.sh /home/user/Desktop/./reboot.sh sh /home/user/Desktop/reboot.sh sh /home/user/Desktop/./reboot.sh ~/Desktop/reboot.sh ~/Desktop/./reboot.sh sh ~/Desktop/reboot.sh
/home/user/ha-bridge/scripts/reboot.sh /home/user/ha-bridge/scripts/reboot.sh /home/user/ha-bridge/scripts/./reboot.sh sh /home/user/ha-bridge/scripts/reboot.sh sh /home/user/ha-bridge/scripts/./reboot.sh ~/ha-bridge/scripts/reboot.sh ~/ha-bridge/scripts/./reboot.sh sh ~/ha-bridge/scripts/reboot.sh
I have copied the scripts to ~/Desktop and also ~/ha-bridge/scripts All scripts have been chmod +x Executing scripts ONLY works from the Desktop (or terminal). I HAVE to right click and select ' Run as Program'. I have also tried making .desktop files for the scripts and running these from the desktop and also ~/.local/share/applications I cannot get scripts to run by double clicking despite following many many guides already. The only way is to have on Desktop and select Run as Program. Scripts run perfectly from Terminal from either ~/Desktop or ~/ha-bridge/scripts.
I'm completely out of ideas.. Hope someone can help. Cheers
try this in your ssh script...
ssh -vvv root@192.168.1.152 reboot now &> /var/tmp/debug.$$
that should give you a lot of debug information to see what ssh was doing.
Thank you rwschul
That is helpful! When I run the script from desktop or terminal with your added code, the scripts executes and writes the debug file.
When I pass the code or try to run the script in HAB, the debug file is not written. So HAB is not running my script, even though it says it has done so...
I can post the output here? I have a debug with just -v so its a bit shorter?
The problem is that HAB won't run the script or pass the code for some reason, the scripts work fine.
EDIT: I just added a new bridge device and added no items at all. Clicking ON or OFF gives a 'Request Executed: Success' message. Even though the request is blank.
stumped ????
well if your wakeup script runs then your ssh script should too. Try adding this as the second line of your script /usr/bin/env > /var/tmp/env.$$
Thanks again. Here's the output. I take it there is nothing in here that poses a security risk for my pc? What do you think?
SHELL=/bin/bash SESSION_MANAGER=local/plex-server:@/tmp/.ICE-unix/2064,unix/plex-server:/tmp/.ICE-unix/2064 QT_ACCESSIBILITY=1 XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu-xorg:/etc/xdg SSH_AGENT_LAUNCHER=gnome-keyring XDG_MENU_PREFIX=gnome- GNOME_DESKTOP_SESSION_ID=this-is-deprecated GTK_IM_MODULE=ibus LANGUAGE=en_GB:en GNOME_SHELL_SESSION_MODE=ubuntu SSH_AUTH_SOCK=/run/user/1000/keyring/ssh XMODIFIERS=@im=ibus DESKTOP_SESSION=ubuntu-xorg GTK_MODULES=gail:atk-bridge PWD=/home/plex XDG_SESSION_DESKTOP=ubuntu-xorg LOGNAME=plex XDG_SESSION_TYPE=x11 GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1 SYSTEMD_EXEC_PID=2088 XAUTHORITY=/run/user/1000/gdm/Xauthority GJS_DEBUG_TOPICS=JS ERROR;JS LOG WINDOWPATH=2 HOME=/home/plex USERNAME=plex LANG=en_GB.UTF-8 XDG_CURRENT_DESKTOP=ubuntu:GNOME INVOCATION_ID=8d99643b17ac4054ac90f31ad1435129 MANAGERPID=1629 GJS_DEBUG_OUTPUT=stderr XDG_SESSION_CLASS=user USER=plex DISPLAY=:0 SHLVL=1 QT_IM_MODULE=ibus XDG_RUNTIME_DIR=/run/user/1000 JOURNAL_STREAM=8:32302 XDG_DATA_DIRS=/usr/share/ubuntu-xorg:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin GDMSESSION=ubuntu-xorg DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus _=/usr/bin/env
On the habridge pc, I did
ssh-keygen ssh-copy-id root@otherpcipaddress
Do i also need to do the same on the pc i wish to send commands to?
I just tried 'sudo reboot now' in habridge and it rebooted the habridge pc
When I tried 'ssh root@192.168.1.152 sudo reboot now' again in terminal, the 152 pc asked for ssh password so maybe I havent set this up correctly.
So... we know the script executes. Its just the ssh that fails. Its very strange that it fails without even a blip in the debug file. This is your path: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin Is ssh installed in one of those directories? Do "which ssh" see what it gives you.
Thanks again, really appreciate this!
plex@plex-server:~$ which ssh
/usr/bin/ssh
huh.... I don't have anything else right off hand. Got other things to attend to. Do you do WhatsApp?
It's bizarre. thanks again for your help. My suspicions are that it's an Ubuntu problem, not habridge.
But i'm at an impasse here. I only want habridge to elegantly shutdown a few PCs, wake them up and shut them down. Seems a waste of a RPi 4 to do those few tasks. Would make much more sense to run on my always on Plex server...
As mentioned before, I have followed all the guides I can possibly find to be able to execute a .sh script on Ubuntu by double-clicking it. None of them work for me. I can't help feeling that is the background issue.
Can do WhatsApp if have any other ideas. Much appreciated :)
Just tried setting my RPi habridge to execute a script in smae format as the ones above and it did it straight away.
It's either an ssh or Ubuntu issue, can't be habridge.
Does user plex need to be in more groups?
Was about to chuck the towel in. As a last throw of the dice, I removed all ssh keys from target PC and both RPi habridge and Ubuntu habridge.
I re-generated the keys on the RPi habridge (which previously worked fine) and habridge no longer worked for ssh calls or scripts. The scripts did work still however when right clicked, execute or from terminal.
It was then that it dawned on me. I was copying ssh keys from the user account, not root. I had copied root keys when I setup the RPi but had not made a note of this.
I enabled the root account on Ubuntu, generated ssh keys, copied to target, boom. All working flawlessly.
Thank you rwschul (and arnieSkyNet) for helping me troubleshoot. And apologies all round for my rookie mistake.
For those that may want to know how to enable the root account and generate ssh keys, here is what I did.
On ha-bridge machine
sudo nano /etc/ssh/sshd_config
CHANGE:
#PermitRootLogin prohibit-password
TO:
PermitRootLogin yes
Save modified file (CTRL+X, enter)
Restart ssh service
sudo systemctl restart ssh
Login as root
ssh root@localhost
Set a password
sudo passwd
You should now be logged in as root. If not, try ssh root@localhost
again
Generate ssh keys
ssh-keygen
Follow the prompts, just hit enter three times, all default is fine.
Copy keys to target machine (root account must be enabled)
ssh-copy-id root@ip_address_of_target_machine
Login to target machine as root (password should no longer be required)
ssh root@ip_address_of_target_machine
:)
Hi all
I have had ha-bridge running on a Pi4 (v5.3.0) for ages and works great for sending WOL packets and ssh boot/shutdown commands to my arcade machines running GroovyArcade (ArchLinux).
I wish to free up the Pi for something else, so installed ha-bridge on my headless Ubuntu Desktop (I also use for Plex) using Docker Compose.
ha-bridge appears to be installed correctly using the following compose file;
`--- version: "2.1" services: habridge: image: lscr.io/linuxserver/habridge container_name: habridge environment:
I tried uploading my backup files from the Pi4 to the Ubuntu machine but they failed. Probably due to version mismatch?
Copying the data from the Pi4 to the Ubuntu results in errors.
These are my config settings that work on the Pi4 (v5.3.0) No scripts required, it just sends the command payload.
I don't know what to do!? Have tried everything I know but no joy.
The log says cannot execute script but in 5.3.0 no scripts are required, it just sends the payload...
Hope you can help!
Cheers
attached db files device.db + ha-bridge.config.zip