How to Connect To Power Manager Over the Network

Power Manager can be connected to and managed remotely over a network. The simplest way to manage deployments of Power Manager is with Power Manager Professional. But this is not the only way. Let's walk through how to use the standard command line tools to remotely connect to a Mac running Power Manager.

Power Manager includes a selection of supporting tools

Power Manager includes command line tool support. The main command line tool is called pmctl and it is available in Power Manager's support folder:

Library > Application Support > Power Manager > Tools.

Before you can remotely connect to Power Manager, you need to set up networking.

Power Manager's System Preference includes a check box to allow remote management. This check box sets up a listening network port that is advertised by Bonjour. The network port is randomly assigned; which is great for avoiding configuration conflicts and other problems, but for this example we want a fixed port number.

Without a fixed port number we would need to look up the advertised Bonjour information each time we want to connect to the remote Mac. This is easy for tools such as Power Manager Professional, but less easy for us humans.

How to Set Up a Fixed Port

  1. Log in to the Mac you want to remotely connect to.
  2. Launch the Applications > Utilities >
  3. Change directory to the Power Manager tools folder using the following command:
    cd '/Library/Application Support/Power Manager/Tools'
  4. Create a new listening socket with the fixed port number of 8765 using the following command:
    ./pmctl listen.applysocket 'unique ID=MySocket' port=8765

    This command asks Power Manager to call listen.applysocket with two parameters.

    The first parameter, unique ID, provides the socket with a unique identifier. You can use this identifier in future commands to refer to the newly created socket.

    The second parameter, port, requests the socket always listen for incoming connections on the port numbered 8765.

Power Manager is now ready to accept secure remote connections.

How to List the Available Sockets

It is important to test any changes, and having just created a new socket we should check it is up and running. We can do this by asking Power Manager to return a list of listening sockets.

Use the same pmctl command line tool and as before:

  1. Ask for a list of listening sockets using the following command:
    ./pmctl listen.sockets

The response to the listen.sockets command may look a little cluttered as it is formatted for parsing by a script, rather than reading:

[{"port"=>8765.000000,"protocol family"=>"IPv4",
"state"=>"listening","unique ID"=>"MySocket",

Notice the state entry is set to listening. This is good news because it confirms the socket is ready and listening for incoming connections.

How to Connect to a Remote Mac

  1. Log in to the Mac you want to connect from.
  2. Launch the Applications > Utilities >
  3. Change directory to the Power Manager tools folder using the following command:
    cd '/Library/Application Support/Power Manager/Tools'
  4. Ask the remote Mac running Power Manager for its build version using the following command:
    ./pmctl -u pm://Mac-Pro.local:8765 build.version

    Note the use of the -u flag and a complete URL using the pm:// schema. You will need to modify this URL to point at your remote Mac. The URL I am using was provided by Power Manager when we listed the available sockets; your URL will be different.

    When connecting you will likely be asked for a user name and password. These are called your credentials, and are those you use to log into the remote Mac:

    Password: (typed characters are hidden)

    pmctl can use Mac OS X's Keychain to avoid needing to enter your credentials every time.

    If all goes well, the build.version command will return a version string such as the one appended below:

    " v4.0.2"

    You have just set up and connected securely to a remote Mac. This technique can be used to remotely manage Macs over any network, including the Internet. pmctl is a powerful tool; it is included as standard, and provides access to every aspect of Power Manager.

This article was posted in , , and and tagged , , , , and .

Published by Graham Miln on