When working with configuration profiles on Jamf Pro, I prefer to download and back them up to GitHub or a similar internal source control tool. The reasons I do this are the following:
- I have an off-server backup for the profiles
- I can track changes to the profiles
Up until recently, this had been a manual process for me where I would download the profiles in question from the server and then upload them to my source control tool.
My process looked like this:
1. Download the profiles from the Jamf Pro server using the Download button.
2. Remove the code-signing and formatting the profile using a process similar to the one described in the link below:
https://macmule.com/2015/11/16/making-downloaded-jss-configuration-profiles-readable/
3. Move the profile to the correct directory in my source control repo.
4. Review changes and commit to the repo.
However, as I’ve started using profiles more, this process got cumbersome and I wanted to automate at least the download part of the process. After some work, I was able to build two scripts which do the following:
- Use the Jamf Pro API to identify the Jamf Pro ID numbers of the configuration profiles.
- Download each profile using its Jamf Pro ID number
- Decode and format the profile
- Identify the display name of the profile
- Save the profile as Display Name Here.mobileconfig to a specified download directory.
For more details, please see below the jump.
I’ve written two scripts for this purpose:
- Jamf_Pro_Mac_Configuration_Profile_Download.sh – This script is designed to download and handle macOS configuration profiles
- Jamf_Pro_Mobile_Device_Configuration_Profile_Download.sh – This script is designed to download and handle iOS and tvOS configuration profiles
For authentication, the scripts can accept hard-coded values in the script, manual input or values stored in a ~/Library/Preferences/com.github.jamfpro-info.plist file. The plist file can be created by running the following commands and substituting your own values where appropriate:
To store the Jamf Pro URL in the plist file:
defaults write com.github.jamfpro-info jamfpro_url https://jamf.pro.server.goes.here:port_number_goes_here
To store the account username in the plist file:
defaults write com.github.jamfpro-info jamfpro_user account_username_goes_here
To store the account password in the plist file:
defaults write com.github.jamfpro-info jamfpro_password account_password_goes_here
Both scripts run in similar ways, with the main difference being which kind of profiles are being downloaded.
To download macOS profiles:
/path/to/Jamf_Pro_Mac_Configuration_Profile_Download.sh
To download iOS and tvOS profiles:
/path/to/Jamf_Pro_Mobile_Device_Configuration_Profile_Download.sh
When run, you should see output similar to that shown below.
The profiles themselves will be stored in either a user-specified directory or, if no directory is specified, a directory created by the script.
The scripts are available below, and at the following addresses on GitHub:
Jamf_Pro_Mac_Configuration_Profile_Download.sh:
Jamf_Pro_Mobile_Device_Configuration_Profile_Download.sh: