-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-compose execute scripts not working #1411
Comments
here is an example of the script. ha-bridge says it executes, but nothing happens. If I run the script manually in Ubuntu it works. The code also runs in terminal as user. #!/bin/bash |
Don't forget habridge runs as root so try running your script via su- rather than sudo I've created a GitHub called launchprog that allows you to put into the habridge on/dim/off launchprog ssh [email protected] sudo shutdown now I'm just finishing it with a -d (debug) option that will leave a window open, so you can see any errors as it runs from root but not pass on the -d as A parameter to the next program, launchprog passes it onto |
I've released it https://github.com/arnieSkyNet/habrunasuser If I shouldn't of posted here, please delete or tell me to delete and I will |
You should check the container to make sure it includes SSH. If not, you'll have to add ssh to the container. If you're using the "lscr.io/linuxserver/habridge:latest" image, you can add ssh by including the following volume in your compose file. home/custom-services:/custom-cont-init.d:ro # ssh service Then in your local custom-services folder, add the file "add-ssh.sh" set the permissions to execute and add the following inside the file: #!/bin/bash echo "**** installing ssh client ****" That should do it. There is info on the net for lscr containers on how to add custom services to their containers.
|
Basically the SSH keys are for the user not root user, hence ssh works via sudo in the terminal but not as root via habridge as root hasn't got the user keys. That's why I wrote launchprog so habridge root can use the users keys |
Hi both Thank you so much for your input, sorry couldn't respond more promptly. Have tried the method from @BuxtonCalvin but still no dice :( I now have a folder called 'custom-services' in /home/username/Compose/habridge In there is the file 'add-ssh.sh' which is executable (chmod +x) Contents of the file are;#!/bin/bash echo "**** installing ssh client ****"
|
It's the ssh keys habridge is running as root You can test it failing by doing su - Note: root on the local machine habridge is running on Took me ages in fact years to work out. This was the issue. So then I wrote that software to make it easier for me and so it would work The other easier way is su - If it works fine, then you can then test it with HA bridge Like I said, I've created a program called launch product that does all this for you if you don't want to create SSH keys for root, which is a real pain because every time you add a new remote machine, do your user, you have to do the same again for root. |
You also need to add a volume for the ssh keys:
Since you know the script works, try running the script from inside the container command line. An easy way to get to it is to use the portainer console feature for the given container. You should be able to change directories from inside the container to your volume where you are holding your action scrips. |
That will work but worth thinking about Root SSH keys, especially in Docker environments, come with significant risks like privilege escalation, weak key management, and lack of isolation. Minimising root access, enforcing restrictions, and securing key storage are critical steps to mitigate risks. |
Hi all
Had habridge working great on a Pi, then on Ubuntu but now trying to get to work in docker-compose.
I have shutdown/reboot and WOL scripts that execute when I right click and 'run as program' in Ubuntu.
Have got ha-bridge running and can execute these scripts (which are stored in /config/scripts) but nothing happens when I do.
Permissions issue? I'm not sure how to fix as there is nothing in the log.
Thanks in advance
The text was updated successfully, but these errors were encountered: