Forcing FOS to reboot from Remote (via ssh login)

  • Hi,

    sometimes the image process stops (due to bad network connection?) but the FOS system is still working. In such situations rebooting the FOS system from remote (FOG management page or ssh login) would be very practical.

    For live systems like SystemRescueCD it is possible to set the root password and activate ssh by boot parameters. It would be perfect if such an functionality was implemented into FOG.

    Thank you for your work anyway.

  • @Tom-Elliott

    Thank you for your answers.

    I will give it a try next time I need some new challenge!

  • Moderator

    @Tom-Elliott Yep that’s a lot easier than tweaking the scripts. Well done!

  • I can see the usecase for this and can actually add this functionality pretty easily. Of course, now with the postinit scripts you can include this yourself.

    The script to do this would be something like:

    echo -e "passwordhere\npasswordohere" | passwd

    Of course this would set the password to all FOS units to the same. You can add in alternate settings too.

    Using the kernel args per host, you could do something along the lines of:
    (Kernel Arg for example)
    Then the script could do something like:

    [[ -n $hostpasswd ]] && echo -e "${hostpasswd}\n${hostpasswd}" | passwd

    Hopefully this helps out.

  • Moderator

    @TrialAndError If you know a little about linux you know enough to modify the inits. I’m not saying you have to do this, just its possible.

    This wiki will allow you to access the contents of the inits (another name is the virtual hard drive) for FOS.

    If I remember correctly there is in /bin or /usr/bin a bunch of bash shell scripts. They all start with “fog.”. The main bash script is called “fog”. In there if you added the code to give root a password it should enable the remote function you seek. Then just repack the inits give them a new name. Test the inits on one system if it does what you need then change the FOG global default for the inits to your new init. Don’t name it the same as an official fog release so an update won’t clobber your hacks.

    Know all you need to know is how to change the password in the fog bash script.

  • @george1421

    1. Automatic reboot would be perfectly enough for my purposes. To avoid boot loops there could be a counter on the server side perhaps?

    2. I am definitly no DAU but a custom init is far beyond my capabilities.

    (The time I would need to learn that would be more than I can save by not walking to the machine that hangs. 😉 )

  • @george1421 said in Forcing FOS to reboot from Remote (via ssh login):

    you or whoever could create a custom init to define a password for root in FOS.

    Or set it up with MFA as well if you were that concerned about security. It’s relatively easy to tie Google-authenticator to ssh, lots of guides online about it.

  • Moderator

    I think what you are asking for is two fold.

    1. If FOS had a watchdog service, in that if the process stops for more than XX minutes the FOS engine would issue an automatic reboot.

    2. This is a little known fact, but if you schedule a debug deploy/capture and then are dropped to the FOS command prompt. If you give root a password you can connect to the FOS engine via ssh. This function is a security feature to not allow remote connections unless the technician does these specific steps. But my point is FOS is fully capable to support what you want. While this (remote connection) won’t be allowed by the official release of fog (again for security reasons), you or whoever could create a custom init to define a password for root in FOS.

    Personally I like the watchdog function a bit more. But then if the process hangs, reboots, and hangs again I can see the system creating a boot loop to no end. Would it be more practical to just let the target computer freeze with the warning message?

    These are just my opinion and not official comments from the FOG project developers.