×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Indi Web Manager Shut down button for Pi

  • Posts: 34
  • Thank you received: 3
Hi Radek,

I tried that:
Sorry, the requested URL 'http://192.168.2.155:8624/api/system/poweroff' caused an error:
Not found: '/api/system/poweroff'

The Indi Web Manager seams to be up to date:

astroberry@astroberry:~ $ sudo pip3 install --upgrade indiweb
[sudo] Passwort für astroberry:
Looking in indexes: pypi.org/simple, www.piwheels.org/simple
Requirement already up-to-date: indiweb in /usr/local/lib/python3.7/dist-packages (0.1.6)
Requirement already satisfied, skipping upgrade: psutil in /usr/lib/python3/dist-packages (from indiweb) (5.5.1)
Requirement already satisfied, skipping upgrade: requests in /usr/lib/python3/dist-packages (from indiweb) (2.21.0)
Requirement already satisfied, skipping upgrade: bottle in /usr/lib/python3/dist-packages (from indiweb) (0.12.15)
astroberry@astroberry:~ $

CS
Reiner
4 years 3 months ago #47787

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375
As the matter of fact I also got this error. @ChrisRowland can you comment on this?
4 years 3 months ago #47789

Please Log in or Create an account to join the conversation.

  • Posts: 554
  • Thank you received: 138
Not sure because the error you get seems to say that the command is not present. This is what you can expect to get if the previous version of Indiweb which doesn't have this command is being used.

However as I said above I've had problems getting reboot and poweroff to work because of security. I would expect this to give a different error but you never know.

The corresponding web interface .tpl and .js files have a couple of buttons implemented. If you aren't seeing this then perhaps there's a snag with what's installed.

The whole security business seems more complex than I thought, you may find that running locally will be fine but sending the commands to another system fails with security issues. I also found that the behaviour was different using the command that Radorek describes and the web interface.

The whole security issue with remote access seems strange. If you are local then reboot and poweroff just run from a normal user account. If you are connecting remotely using VNC the same applies. But with ssh, running as apparently the same user, they fail because of security and you need sudo reboot plus a password.

I'll try to look at this some more and find ways round these issues. I'd prefer not to run the system with no security at all although if, like me the remote system is a Pi Zero running indiserver and a telescope driver there's minimal implications.

If anyone wants to help feel free. That's the point of open source software.
4 years 3 months ago #47810

Please Log in or Create an account to join the conversation.

  • Posts: 407
  • Thank you received: 74
Dont know if it could be incorporated into Indi Web interface but you can using SSH without a password to shutdown/reboot a remote PI without compromising security

Read this www.raspberrypi.org/documentation/remote.../ssh/passwordless.md

BUT user is running client on Windows which means you will have to install SSH client (e.g. PUTTY) - and no PUTTY is not a virus its been around for years :-) Although I believe MS have OpenSSH as an option now days - never used their version.

Putty just issues a command via CLI - so REBOOT SHUTDOWN no problem and this can be incorporated into a PUTTY profile for the required RPI so once set up you can just create a simple Windows job to call Putty with the profile. Works 99.99999% of the time

As I say not sure if that could be incorporated into a browser back end.

Might help.
RPI3 Ubuntu 16.04 / AMD desktop Kstars under Ubuntu 16.04 Mounts :azeq6 ,SWAZGoTo

RPI3 Fedora testing out on AMD desktop Fedpra 28 - running kstars 2.9.4 , Indilib 1.7.4 ?????
4 years 3 months ago #47811

Please Log in or Create an account to join the conversation.

  • Posts: 983
  • Thank you received: 375
So it seems that pip does not install the latest INDI Web Manager.
4 years 3 months ago #47824

Please Log in or Create an account to join the conversation.

  • Posts: 554
  • Thank you received: 138
I posted a fairly lengthy message which seems to have vanished.
In brief:
Stash's suggestion works for getting SSH to start without needing a password but the reboot and poweroff commands still need sudo support.
sudo visudo can be used to add an exception for the reboot and poweroff commands.
This gives the ability to reboot or poweroff from a .bat or .sh script, maybe as part of the Ekos close down.
I think Indiweb needs sudo adding to the commands to make them work but I wonder if that's needed. I thought it would be an easier way to implement power off and now I'm not so sure.

I've no idea why pip doesn't install this, my code has been pushed to indiwebmanager and that's all I can do.

I don't see a security issue with this, it requires a number of deliberate steps to implement and if you don't want it then don't do them.
4 years 3 months ago #47829

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 3
In parallel I´ve took a look on indigo, wich also is based on indi (as I understand)
Here I have the function reboot and shutdown in the server area. And it works perfect.
So this shoud be possible
4 years 3 months ago #47835

Please Log in or Create an account to join the conversation.

  • Posts: 407
  • Thank you received: 74

Well there is - after some testing and trying to find my old RPI Zero SD card (overwritten) you can - well with Windows Putty - have a Putty profile that contains the command to issue - e.g. sudo reboot or sudo shutdown -h now and it logs in with Private keys and issues the command AND does not ask for a password. It then does command in the putty profile.

NOTE THIS IS VERY VERY VERY OPEN TO HACKERS ETC ETC AND YOU DO IT AT YOUR RISK - hell what's a bit of risk. OK a lot as you/anyone can do anything - you did say you didn't care about security LOL. SO PLEASE OTHER USERS DO NOT TELL ME THE OBVIOUS SECURITY PROBLEMS.

Key is alter the sudoers file ( I use an extra file in /etc/sudoers.d which contains astroberry ALL=(ALL:ALL) NOPASSWD: ALL

No idea if you can create a backend script or a bit of Javascript to enable stop/reboot via Web HTML etc but from Windows you just create a command line for putty o start with a set profile name - \path\name\to\putty.exe -load "mysession" where mysession is the saved profile name.

I tested this on a RPI zero(W) running headless and connecting to my local WiFi. Still allows Astroberry/Indi Web etc and even NOVNC (no desktop just black screen in centre obviously)
RPI3 Ubuntu 16.04 / AMD desktop Kstars under Ubuntu 16.04 Mounts :azeq6 ,SWAZGoTo

RPI3 Fedora testing out on AMD desktop Fedpra 28 - running kstars 2.9.4 , Indilib 1.7.4 ?????
4 years 3 months ago #47961

Please Log in or Create an account to join the conversation.

  • Posts: 554
  • Thank you received: 138
It's possible to tie the sudoers down a bit more by specifying just the commands you want to run without a password:
user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown

In Windows a one line batch file will do what's required:
start cmd.exe /C "ssh This email address is being protected from spambots. You need JavaScript enabled to view it. sudo poweroff"

It's necessary to set SSH to run without requesting a password, that's well documented.

I see the security issue a bit like not having a lock on my fridge. If someone's broken into my house they can open my fridge and steal my beer - which reminds me...

Chris
Last edit: 4 years 3 months ago by Chris Rowland. Reason: Typo
4 years 3 months ago #47963

Please Log in or Create an account to join the conversation.

  • Posts: 407
  • Thank you received: 74
Yes I had already done the "user only" sudoers but it didn't work every time for some reason. Plus I wanted to change things to stop having to put in the password on any command - lazy I know.

No good looking in my fridge its empty except Thursday (shopping day)!

I presume you put the extra lines in a user file under sudoers.d so that updates dont clear out your mods ?

I dont use Windows SSH as it doesn't work across all Windows O/S (yes I still have some "older" versions running)
RPI3 Ubuntu 16.04 / AMD desktop Kstars under Ubuntu 16.04 Mounts :azeq6 ,SWAZGoTo

RPI3 Fedora testing out on AMD desktop Fedpra 28 - running kstars 2.9.4 , Indilib 1.7.4 ?????
4 years 3 months ago #47986

Please Log in or Create an account to join the conversation.

  • Posts: 269
  • Thank you received: 53
Chris
After a bit of experimenting you could try the following:
Add a text control to the web page to capture the password to send to sudo using the -S option which accepts a password through stdin. The only downside is that the password is sent as plain text.
If there is no password assume sudo is not needed and simply execute "poweroff"
Otherwise execute: echo <password> | sudo -S poweroff
e.g. I have tried the following with success on the command line in Ubuntu 20.04:
echo "mypassword" | sudo -nS reboot
echo "mypassword" | sudo -nS poweroff

Or I could have a crack it myself

Edit: added the -n option to suppress the password prompt
Last edit: 3 years 3 months ago by Ken Self. Reason: add -n option
3 years 3 months ago #65075

Please Log in or Create an account to join the conversation.

  • Posts: 269
  • Thank you received: 53
Correction. Its just:
echo "mypassword" | sudo -S reboot
echo "mypassword" | sudo -S poweroff

Doesn't work with -n
3 years 3 months ago #65080

Please Log in or Create an account to join the conversation.

Time to create page: 3.500 seconds