Git Product home page Git Product logo

Comments (9)

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

It seems to me like the issue is much simpler than you think. I think the user does not have permissions to shutdown the computer.

On your iMac, try to open the terminal and execute the shutdown command (without ssh). Youā€™re probably going to see a prompt for your password.

There are ways to change what commands a user can execute without sudo, try that.

from homebridge-wol.

guysbrown avatar guysbrown commented on May 14, 2024

Thanks for the response.

I enabled password-less sudo on both machines so don't think a password prompt would happen as the command was "sudo shutdown -h now" rather than just "shutdown -h now".

I tried to create an executable script on the iMac to try it a different way. I used osascript -e 'tell app "System Events" to shut down' instead of shutdown -h now as that shouldn't ask for a password.

I can run ssh 192.168.1.82 sudo ~/rmShutdown.sh via terminal on the Mac mini and it works fine. However when I try use it as the shutdownCommand command I get the same message.

[4/7/2019, 7:53:27 PM] [iMac] An error occured while trying to shut down "iMac" (192.168.1.xx): Error: Command failed: ssh 192.168.1.xx sudo ~/rmShutdown.sh
Permission denied, please try again.
Permission denied, please try again.
Received disconnect from 192.168.1.xx port 22:2: Too many authentication failures
Disconnected from 192.168.1.xx port 22

Thoughts?

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

Ensure that your SSH keys are correctly setup. If the permission issue is not on the iMac side, itā€™s on the other side. Notice how it repeats the error message and mentions an authentication error, typical for SSH issues.

If you have setup keys for the user, ensure that the shutdown command is run by your user by testing a shutdown command like ā€œwhoamiā€.

Also, thank you for posting about your findings along the way! I like to imagine that it helps others when debugging issues.

from homebridge-wol.

guysbrown avatar guysbrown commented on May 14, 2024

Not sure if this is related but the switch always stays On even when the iMac is sleeping! The only time it shows as Off is when the iMac has been completely shut down.

from homebridge-wol.

guysbrown avatar guysbrown commented on May 14, 2024

Regarding the SSH keys. It works via terminal but not via Homebridge. Could it be that it is running as a different user? I would have thought that using username@ would have sorted that?

Maybe Iā€™ll delete the SSH keys and start from scratch.

from homebridge-wol.

guysbrown avatar guysbrown commented on May 14, 2024

OK, so I deleted the SSH keys and recreated them and still no joy!

I can SSH via Terminal from the Mac mini to the iMac without a password and can execute the commands without issue.

However when done through Homebridge / Homekit I still get the permissions error!

Could the ā€œPermission deniedā€ error be due to Homebridgeā€™s / Nodeā€™s ability to run the SSH command rather than authenticating with the remote server? Or am I just reaching?

I am stuck!!!

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

Regarding the first part, this is likely due to the mac responding to pinging whilst sleeping. This is a known issue without any real solution as of now. If your interested, there are other issues around discussing this further.

As for SSH keys. Yes, the decision should be automatic if you use me@..., if you're running as the same user as SSH looks in ~/.ssh for keys. Usually all keys are in /Users/me/.ssh even though it may be for SSH user someone-else. You should try to force SSH to use specific keys by using ssh -i /Users/me/.ssh/id_rsa (or whatever your key is called) in the shutdown command.

from homebridge-wol.

guysbrown avatar guysbrown commented on May 14, 2024

Awesome, that fixed it. Thanks šŸ™

Now I just need to figure out how I am going to use it since the iMac responds to Ping whilst asleep!!!

At least I can see if it is on and shut it down using Homekit now :)

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

@guyssbrown This is a known issue due to iMacs responding to pings even when they're asleep. There are some issues you can find here which discusses the issue in depth.

When this milestone has been resolved, the issue will have been mitigated:
https://github.com/AlexGustafsson/homebridge-wol/milestone/1

Closing as this is solved. Feel free to open new issues if you stumble upon further trouble.

from homebridge-wol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.