Change Hostname for macOS Devices

This article shows you how to change the hostname of a macOS device as well as how to update the Device Name in JumpCloud to reflect the new hostname.

Changing the macOS Device Name

You can update the hostname either manually on the device or via JumpCloud Commands.

Before renaming a macOS device, remember that there are three different references for Hostnames along with their nuances. You can either update the device name manually or use the Commands Tab in the Jumpcloud Admin Portal.

Important:

When installing the JumpCloud Agent, the Device Name (Display Name) is automatically mapped to the configured macOS ComputerName. While these attributes can be updated on the macOS system after agent install, the Device Name (Dispaly Name) in JumpCloud does not update automatically. However, the 'Hostname' in the JumpCloud Admin Portal will update to reflect local device changes (see the following image). 

Hostname highlighted in the Device Details in the JumpCloud Admin Portal.

Hostname types in macOS:

  • LocalHostName: This name will reflect the Local Bonjour Computer Name with ‘.local’ appended to the Hostname.  These can be set differently so review carefully. This is the name that gets set during the initialization of your macOS device on the first time set up of the device.
  • ComputerName: This name will map to the “Hostname” reference within the JumpCloud Admin Portal. Generally this name is the same as the LocalHostName upon the first time set up of your macOS device.
  • HostName: The underlying MacOS System via the Terminal also has a ‘Hostname’ reference that can be set as well as a local ‘hosts’ file to override DNS, which is outside the scope of this article.

Changing the macOS Device Name Manually

To change the hostname on macOS 12 Monterey and prior, follow these steps:

  1. Go to System Preferences > Sharing.
  2. Click Edit to update the Computer Name.
    macOS System Preferences Sharing Settings.
  3. Enter the desired name and click OK.
    Sharing Settings in macOS System Preferences.

To change the hostname on macOS Ventura 13 and newer, follow these steps:

  1. Go to System Settings > General > Sharing.
  2. Click Edit to update the Local hostname.
  3. Enter the desired name and click OK.
    Message prompt to select hostname for device

Wait up to 30 minutes for the JumpCloud Agent to update the device’s information to the newly changed hostname.

Device Overview with Device Name highlighted

Next, update the JumpCloud Device Name based on the updated macOS hostname. See Using PowerShell to Update the Device Name to reflect the new Hostname.

Important:

There are only two methods to update the JumpCloud Device Name: either manually via the API, or via the JumpCloud PowerShell Module. See the following section for instructions using the PowerShell Module.

Changing the macOS Device Name Using Commands

After the JumpCloud Agent is installed, you can also rename the device from the Commands Tab in JumpCloud Admin Portal using the standard MacOS Admin command-line utilities. For more information on commands, see Get Started: Commands.

Changing macOS Hostname(s) from the Command-Line:

To create a new Command within JumpCloud for macOS, follow these steps:

  1. Log in to the JumpCloud Admin Portal.
  2. Go to DEVICE MANAGEMENT > Commands.
  3. Click ( + ), then choose Command.
  4. Name the command (for example, Rename Hostname for macOS).
  5. Using the following command as a template, enter the new name of the device where it says NEW_HOSTNAME_GOES_HERE and enter in the Command box.
  6. Name the command. (e.g. Rename Hostname for macOS)
  7. Edit the following command and enter the new name of the device where it says NEW_HOSTNAME_GOES_HERE.


#Change Hostname
sudo scutil --set HostName NEW_HOSTNAME_FQDN_GOES_HERE

#Change LocalName
sudo scutil --set LocalHostName NEW_HOSTNAME_GOES_HERE

#Change ComputerName
sudo scutil --set ComputerName NEW_HOSTNAME_GOES_HERE

#Flush DNS Cache
dscacheutil -flushcache

  1. Save and then bind this Command to the device you want to update via the Devices tab.

Important:

Please ensure you are only binding this command to one device at a time.

  1. Once you’ve bound the Command to the Device, Run the command and wait for a result code of 0 (Success).
  2. Upon successful execution of the command, it is highly recommended to restart the device.

Next, update the JumpCloud Device Name based on the updated macOS hostname. See Using PowerShell to Update the Device Name to reflect the new Hostname.

Using PowerShell to Update the Device Name to reflect the new Hostname

To properly change the Device Hostname to match macOS device’s hostname in the JumpCloud Admin Portal follow the directions below.

You will need to have the PowerShell Module installed on your local device. See Install the JumpCloud PowerShell Module.

  1. Open PowerShell on your device and type the following command. PowerShell will then prompt you for your JumpCloud Administrator API Key to authenticate to your JumpCloud Org via the API.
    Connect-JCOnline
  2. Next you’ll want to query JumpCloud to confirm current hostname and displayName of the macOS device you’re wanting to update:
    Get-JCSystem -hostname MACOS_HOSTNAME_GOES_HERE | select hostname, displayName
    You should see an output similar to the following:
    hostname displayName ————- —————– work-macos-1 macadmins-Mac.local
  3. Once you’ve verified that the hostname is the correct hostname you want it to be, we will then force change the JumpCloud displayName (Device Name) to be the current hostname.
    Get-JCSystem -hostname MACOS_HOSTNAME_GOES_HERE | Set-JCSystem -displayName INSERT_HOST_NAME_HERE
    You should then see an output similar to the following if done properly:
    hostname displayName ————- —————— work-macos-1 work-macos-1
Back to Top

Still Have Questions?

If you cannot find an answer to your question in our FAQ, you can always contact us.

Submit a Case