Home Forums OS X Server and Client Discussion Misc. Remote SSH restart

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #363053
    fherbert
    Participant

    Has anyone been able to restart a mac from a ssh remote command. Ie from remote machine issue command like this:

    ssh user@remotemachine /sbin/restart

    I know that I can use ARD for this, but i would like to integrate something like this into the back end of a web page and i need to be able to send a restart command and run a script remotely on the machine… I have experimented with running an osascript command to restart finder, but this will time out if applications are running that require user input to shutdown.
    Anybody tried this or have any suggestions??

    #363054
    maccanada
    Participant

    Should work fine using reboot instead of restart…of course you’ll need appropriate permissions on the end machine to execute a reboot

    #363066
    fherbert
    Participant

    A reboot or restart works fine when I remote onto the machine to the command line via ssh, however, what I need to be able to do is just send a command to it.
    When I send a command like ssh user@remotemachine ‘/sbin/reboot’ i get a “command not authorised” or something similar… the idea is not have to remote completely onto the machine as I want to run a script on an admin machine that automatically runs a script then restarts the remote machine…

    #363075
    maccanada
    Participant

    As I said, it comes down to permissions. You have 2 options really:
    1. Enable root account on the client and send the command as root – much like the SyncServices folder, I recommend you stay away from this

    2. Edit the sudoers file to allow a user to execute the required command – man sudoers goes through it all in some detail, but basically something like:
    helpermonkey stampy = NOPASSWD: /bin/reboot
    should allow the user helpermonkey, run the reboot command on the machine stampy without putting in a password
    You should use visudo to edit the file, and take a backup of it in case things don’t work out right.

    #363097
    fherbert
    Participant

    That sounds like the sort of thing I will have to do. I will give it a go.
    Thanks.

    #363393
    fherbert
    Participant

    I have modified my /etc/sudoers file but this still does not allow me as an admin to perform a restart from the command line. I believe I may need to modify /etc/authorization section “system.restart”. I have searched the web for any decent documentation on what exactly the “RestartAuthorization:restart” and other mechanisims are, but I am unable to find any info. Does anyone know how I can modify (or If I have to) /etc/authorization in order to allow an admin user to restart from the command line?

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Comments are closed