Home › Forums › OS X Server and Client Discussion › Misc. › Remote SSH restart
- This topic has 6 replies, 3 voices, and was last updated 19 years, 6 months ago by
afp548contributor.
-
AuthorPosts
-
September 1, 2005 at 11:05 am #363053
fherbert
ParticipantHas 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??September 1, 2005 at 12:38 pm #363054maccanada
ParticipantShould work fine using reboot instead of restart…of course you’ll need appropriate permissions on the end machine to execute a reboot
September 1, 2005 at 8:23 pm #363066fherbert
ParticipantA 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…September 2, 2005 at 2:35 am #363075maccanada
ParticipantAs 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 this2. 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.September 2, 2005 at 8:44 pm #363097fherbert
ParticipantThat sounds like the sort of thing I will have to do. I will give it a go.
Thanks.September 28, 2005 at 11:43 pm #363393fherbert
ParticipantI 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?
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed