Change Hostname for macOS Devices

A hostname is a unique identifier assigned to a device or server on a network that is used for network communication and identification purposes, specifically for Domain Name System (DNS).

When you install the JumpCloud agent on a device, it's assigned an admin-friendly name called a Device Name (or Display Name). The display name can be customized in JumpCloud, but those changes aren't reflected on the local hostname.

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 Local Hostname

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 JumpCloud Commands.

Important:

When installing the JumpCloud Agent, the Device Name (Display Name) is automatically mapped to the configured macOS Computer Name. While these attributes can be updated on the macOS devices after agent install, the Device Name (Display Name) in JumpCloud does not update automatically. The 'Hostname' value in JumpCloud will update to reflect local device changes.

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 Local Hostname Manually

To change the hostname on macOS 12 Monterey and prior:

  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:

  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

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

To verify the device's hostname in JumpCloud:

  1. Log in to the JumpCloud Admin Portal.
  2. Go to DEVICE MANAGEMENT > Devices.
  3. Select the Devices tab.
  4. Locate the device in the list and select it.
  5. Go to the Insights tab and scroll down to Network to view the Hostname.

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.

Using Commands to Change the Local Hostname

You can also update the device's local hostname using JumpCloud Commands from the Commands and standard macOS command-line utilities. For more information on commands, see Get Started: Commands.

To create a new Command within JumpCloud for macOS:

  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 Hostname

Use the following JumpCloud PowerShell command to update the JumpCloud Device Name to match macOS device’s hostname.

You'll need to have the PowerShell Module installed on your local device. See Install the JumpCloud PowerShell Module to learn more.

  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

  1. 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
  1. Once you’ve verified that the hostname is correct, issue the following command to 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:
    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