-1

I am trying to reboot a Unix based machine with SSH on windows. I am using PuTTY command, it looks like this :

putty.exe -ssh user@my.ip.add.ress -pw password -m reboot.txt -t

And the reboot.txt contains :

reboot

When I am connecting on ssh by myself and use the "reboot" command my machine is rebooting, it is not with the putty command line.

Do you have an idea of a putty command to reboot my machine ?

Thanks a lot !

Raptor
  • 53,206
  • 45
  • 230
  • 366
DamienDne
  • 27
  • 1
  • does the SSH user have the permission to reboot the machine remotely without `sudo`? – Raptor Oct 25 '22 at 08:20
  • Yes, when I reboot it myself (so with cmd and ssh connexion) i am not using "sudo" and it works – DamienDne Oct 25 '22 at 08:22
  • 1
    *"it is not with the putty command line"* => so what does it do? do you get any error? And this is not a [programming question](https://stackoverflow.com/help/on-topic). You better move it to [su]. – Martin Prikryl Oct 25 '22 at 08:55
  • The terminal close itself and nothing more appears. Furthermore my machine does not reboot. Ok I'm sorry I did not know Super User exists – DamienDne Oct 25 '22 at 10:58

1 Answers1

-1

There are two reasons that I can think of for this to not work.

  1. The putty instance is closing before the reboot times out (60 seconds by default for most systems) which when your connection closes it kills the process. You can resolve this by either sending NOHUP or by forcing reboot immediately with /sbin/shutdown -r now

  2. Your user is not the one processing the script, which the user that is processing the script does not have permissions to shutdown the machine. You can log a whoami from the putty command to see which user is calling shutdown.

Here is a guide on reboot: https://www.cyberciti.biz/faq/howto-reboot-linux/#:~:text=To%20reboot%20Linux%20using%20the%20command%20line%3A,reboot%20%E2%80%9D%20to%20reboot%20the%20box.

Jordan Casey
  • 955
  • 9
  • 16