How to Remotely Restart or Shut Down Your Mac

Don't Power Off a Sleeping Mac; Use a Remote Restart Instead

Remote Login - Sharing Preference pane
Screen shot courtesy of Coyote Moon, Inc.

Have you ever found yourself in a situation where you need to shut down or restart your Mac, but need to do so from a remote computer that isn't the Mac you actually want to restart? This is a good way to restart a Mac that won't wake from sleep using conventional methods.

For a number of reasons, this happens occasionally around our home office. It may happen because the old Mac we use as a file server is stuck and needs to be restarted.

This Mac lives in a location that's a bit inconvenient: upstairs in a closet. Perhaps in your case, you come back from lunch and discover that your Mac won’t wake from sleep. Sure, we can run upstairs and restart the Mac we're using as a server, or for the Mac that won’t wake from sleep, you can simply hold the power button in until it turns off. But there's a better way, one that for the most part is a better response than simply hitting the power button.

Remotely Accessing a Mac

We're going to cover a couple of different ways to remotely restart or shut down a Mac, but all of the methods mentioned here assume that all of the computers are connected on the same local network in your home or business, and not situated in some far-flung location that's only available by means of an Internet connection.

That’s not to say you can’t access and control a remote Mac over the Internet; it just takes more steps than we're going to use in this simplified guide.

Two Methods to Remotely Access a Mac

We're going to look at two methods for remote connections that are built into your Mac. This means no third-party app or special hardware device is necessary; you have everything you need already installed and ready to be used on your Macs.

The first method makes use of Mac’s built-in VNC (Virtual Network Computing) server, which on the Mac is commonly called screen sharing.

The second method makes use of Terminal and its support for SSH (Secure Shell), a network protocol that supports secure encrypted remote login to a device, in this case, the Mac you need to restart or shut down.

If you're wondering whether you can restart or shut down a Mac using a PC running Linux or Windows, or perhaps from your iPad or iPhone the answer is yes, indeed you can, but unlike the Mac, you may need to install an additional app on the PC or iOS device in order to make the connection.

We're going to concentrate on using a Mac to restart or shut down another Mac. If you need to use a PC, we’ll provide some suggestions in a bit for software you can install, but we won’t be providing a step-by-step guide for the PC.

Using Screen Sharing to Remotely Shut Down or Restart a Mac

Although the Mac has native support for screen sharing, this feature is disabled by default. It needs to be enabled using the Sharing preference pane.

To turn the Mac’s VNC server on, follow the instructions outlined in:

How to Enable Mac Screen Sharing

Once you have Mac’s screen sharing server up and running, you can use the procedure outlined in the following article to take control of the Mac:

How to Connect to Another Mac's Desktop

Once you have made the connection, the Mac you're accessing will display its desktop on the Mac you're sitting at. You can use the remote Mac just as if you were sitting in front of it, including selecting the ShutDown or Restart command from the Apple menu.

Using Remote Login (SSH) to Shut Down or Restart a Mac

The second option for taking control of the Mac is to use the Remote Login capabilities. Just as with Screen Sharing, this feature is disabled and must be turned on before you can make use of it.

  1. Launch System Preferences, either by clicking the System Preferences icon in the Dock, or selecting System Preferences from the Apple menu.
  1. In the System Preferences window, select the Sharing preference pane.
  2. In the list of services, place a check mark in the Remote Login box.
  3. This will enable remote login and display options for who is allowed to connect to the Mac. I highly recommend limiting the ability to connect to your Mac to yourself and any Administrator account you have created on your Mac.
  4. Select the option to Allow access for: Only these users.
  5. You should see your user account listed, as well as the Administrators group. This default list of who is allowed to connect should be enough; if you do wish to add someone else, you can click on the plus (+) sign at the bottom of the list to add more user accounts.
  6. Before you leave the Sharing preference pane, be sure to write down the IP address of the Mac. You'll find the IP address in the text shown above the list of users allowed to log in. The text will say:
  7. To log into this computer remotely, type ssh username@IPaddress. An example would be
    ssh casey@192.168.1.50
  8. The number sequence is the IP address of the Mac in question. Remember, your IP will be different than the example above.

How to Remotely Log Into the Mac

You can log into your Mac from any Mac that is on the same local network. Go to another Mac and do the following:

  1. Launch Terminal, located in /Applications/Utilities.
  2. Enter the following at the Terminal prompt:
  3. ssh username@IPaddress
  4. Be sure to replace “username” with the username you specified in step X above, and replace IPaddress with the IP address of the Mac you wish to connect to. An example would be:
    ssh casey@192.169.1.50
    	
  1. Press enter or return.
  2. The terminal will likely display a warning that the host at the IP address you entered can’t be authenticated, and ask if you wish to continue.
  3. Enter yes at the Terminal prompt.
  4. The host at the IP address will then be added to a list of known hosts.
  5. Enter the password for the username you used in the ssh command, and then press enter or return.
  6. The terminal will display a new prompt that usually will say localhost: ~ username, where username is the username from the ssh command you gave above.

    Shutdown or Restart

  7. Now that you're remotely logged into your Mac, you can issue either a restart or shutdown command. The format is as follows:
  8. Restart:

    sudo shutdown -r now
  9. Shutdown:

    sudo shutdown -h now
  10. Enter the restart or shutdown command at the Terminal prompt.
  11. Press enter or return.
  12. You will be asked for the password for the remote user's account. Enter the password, and then press enter or return.
  13. The shutdown or restart process will begin.
  14. After a short time, you'll see a “Connection to IPaddress closed” message. In our example, the message would say “Connection to 192.168.1.50 closed.” Once you see this message, you can close the Terminal app.

Windows Apps

UltraVNC: Free remote desktop app.

PuTTY: SSH app for remote login.

Linux Apps

VNC Service: Built into most Linux distributions.

SSH is built into most Linux distributions.

References

SSH man page

Shutdown man page