Send one string reboot command via ssh?

Discussion in 'Mac OS X Lion (10.7)' started by lokiju, Jun 22, 2012.

  1. lokiju macrumors 6502

    Jun 10, 2008
    I know how to reboot my Mac running Lion via SSH and using the method of connecting, elevating via sudo to root and then sending the reboot command.

    However I have a situation where the only device I can connect to currently is a router in my network that can do simple commands and only without interaction in a sense that I cannot send a command that then requires another step like an answer or elevation. Basically no prompting will work as it is not interactive.

    So I'm wondering if I can send a reboot command to my Mac from this interface that will include all the required syntax in one string to define the computer by IP, what to do (reboot) and also who to run the command as, including the credentials of root that is required for rebooting via SSH.

    Something like ssh root@ -pw thisismypassword shutdown -r now

    Is there any way to accomplish this?

    I can ping my Mac from this router and see it's replying but I cannot ssh into it as I have no other device other than this router to connect via ssh from.
  2. larkost macrumors 6502a

    Oct 13, 2007
    In order to do this you are going to have to do this without a password (at least on the remote computer). This is actually very doable using sudo, which will allow you to setup a great number of cases including never having to supply a password (for given users) or even never having to supply a password for a specific user executing a specific command (like reboot).

    Take a look at 'man sudo' for some examples.

Share This Page