-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about Macs with existing LAPS account #6
Comments
Hi @jelockwood So your options 1 and 2 are both very doable but I've not implemented these workflows as they would both require an existing admin password to be inputed in plain text somewhere in the script or in a Jamf variable. One idea you could do is to have the existing account removed just before the LAPS script runs. That way it will not interfere with the LAPS script creating the new one. Alternatively as you have pointed out that JAMF Connect can indeed create and cycle an existing account. This can be used with my script if the script is placed in a prestage where it runs before the user has been created or logged in. The issue with this is that JAMF Connect sets the password to the recovery key and then there isn't a way for my script currently to cycle the password after then. I guess in theory you could add some logic to check if the recovery key and local password are the same and then have the LAPS account password cycled but to me it's just adding more complexity and more points of failure. I have set my script up for many customers where it runs during the prestage process and is created before any user logs in through JAMF Connect. This workflow is mainly for zero-touch provisioning where an IT Engineer is not creating an admin account with JAMF Connect but rather the end user logs in and creates a standard account. Granted this does leave the LAPS account without a secure token but then you will still have the option to use the recovery key if you ever do need to unlock the drive. |
@PezzaD84 So $10 would be the default password (encoded) and $11 would be the JSSID i.e. the computer ID record number of the computer so this can be used to retrieve the FileVault recovery key. The Jamf API does not use a serial number for this record unlike the classic API. It would then check to see if the existing password equals the FileVault recovery key, if not it then tries the default password. Obviously if there is an existing record with an existing random password that should be tried as well. I put some example values in as I was trying this outside of Jamf.
|
@PezzaD84 Potentially I could write my own script which for example puts initial values in the LAPS Secret and LAPS Crypt Key extension attributes. I could use a smart group so your script only runs after the extension attributes are filled in and hence when your script runs it treats it as an ongoing process and just updates the content. |
Hi @jelockwood Sorry I completely forgot to reply to your last message. Yes this would work but again would need to pass a password in plain text at some point. In reply to the latest message, there is some logic in the script that checks if the script has run before and to check for accounts with the same name specified in the JAMF variable. If the script has not run and the account name doesn't exist locally then the creation runs. If the script has not run and the account name exists then it will fail. |
@PezzaD84 I need to understand your script logic and how it determines if it has not run before and therefore would fail for an existing account. I need to trick your script to thinking it has run before and for it to simply read the values and carry on as normal. |
@jelockwood |
@PezzaD84 |
Hi @jelockwood I've attached an updated script which now includes the ability to run against an existing local admin account. Please now this is still in beta testing so there could still be the odd bug here and there. So far testing has been working really well and the existing password is being cycled and reset and then managed by the existing LAPS policies as normal. You will need to encode the password first using the attached script which will give you a secret key and the encoded string which you need to now specify in $10 and $11. My current policy looks like this but it could change in the final documentation once I refine it a little. Encode Existing Password.zip |
@PezzaD84 I have started incorporating it in to my workflow. I have created a script for use as a Jamf Policy. This script uses an encryption 'Secret' to encrypt the initial default password and then writes the encrypted password and the 'Secret' to the extension attributes as initial values. Your modified script should be able to read them and then use them as the starting point. I will be intending to combine your script, my script to set initial values and then link to Super via another script I am writing so that Super can use the LAPS credentials itself. Have a look at the following which is the script I wrote to populate (your) LAPS extension attributes. I will be using a smart group to look for computers in Jamf with empty values, and then fill them in. Once filled in i.e. not empty, I will then have another smart group to trigger running your LAPS script. See - https://github.com/jelockwood/Super-Glue/blob/main/laps-populate.sh |
Nice, I'll check out what you've been working on when I get a free moment. |
@PezzaD84 Oops, re-read above and see the latest script and settings including API credentials, however if you have a list of Jamf permissions you need for the api account that would still be useful. I will give this a try tomorrow. |
@PezzaD84 I am however not clear on what policies need to be created, your comment above implies an additional policy but is not clear on what trigger it has compared to the other policies. The notes seem to imply that there would be two copies of the "LAPS | Create local admin & password" policy. How do they behave differently? Is this by having one without the admin account values specified? I would not want it to accidentally reset the local admin account and destroy the secure token/volume ownership status. It might be clearest to list all the policies including the additional one so I can double check my setup. |
@jelockwood Your question about Filevault is a good one which I still haven't tested fully yet so I would test it out before you roll this out to an estate. This version I've sent you isn't public yet as I do need to test it on filevault devices and check the behaviour is ok. |
@PezzaD84 I enabled the other policies and did another Jamf Policy command, I can see it changed the value of the extension attributes and I then decoded the new value and checked this on the Mac for the user account in Terminal, System Preferences etc, and also checked it still had a secure token and volume owner ship. All good so far, it was changed, the decoded values worked, it still has a secure token and volume owner ship so FileVault should also be unaffected. I am however struggling with Jamf Self Service on my test Mac. It is crashing when launched. You provide a laps.pkg installer, what does this install and where? If it is an app to retrieve the password I could manually run it if I know where it is. (I have installed separately Swift Dialog.) On a different Mac I am able to successfully via Jamf Self Service use the LAPS Self Service option to retrieve and decrypt a value. |
@PezzaD84 So, looking good. |
@PezzaD84 Whilst the first run seemed to successfully update the Jamf extension attributes and the actual account, I did end up unable to login with that account. I rebooted in to recovery and reset it back to the original default password and was able to login. Now it is running the first one time policy and setting the extension attributes to new randomised values but DOES NOT actually change the account password. I cannot see any error messages, the laps decrypt policy decrypts successfully but testing via Terminal, screen saver and System preferences suggests it did not actually change the account password. I flushed the policy so it would run again as a first time command and I also emptied the extension attributes first. Can you add an additional log command to show whether your script has actually changed the account password. It looks like the first run is now only generating new values and not changing anything. Here is what the policy results indicate Executing Policy LAPS | Create local admin & password copyDownloading LAPS.pkg... |
@PezzaD84 |
@PezzaD84 I had deliberately restored the initial default password, I had cleared the extension attributes and I had flushed the one-time policy. It was then not doing a password change but did set the extension attributes. It turns out your script logic has a check to see if the log file already exists, if it does then it skips changing the password but does set the extension attributes and hence gets out of sync. Normally this one time execution for an existing local admin with a default password will only ever be run once but you might want to logic at your script logic regarding this. I then cleared the log file and the other stuff tried again and this time it has both set the extension attributes and changed the password for the account from the default initial value. I can now double check FileVault etc. as I was intending 😄 |
Hi @jelockwood Sorry for the delayed reply work has been hectic! So yes thats why I'm currently running the new script as a "run once" because otherwise it will try to reset the existing local admin password and ends up putting the whole thing out of sync. |
@PezzaD84 This was what I was starting to suspect based only my results. I will try this and see how it goes. Good thing I had not rolled it out to other Macs. 😉 |
@PezzaD84 However it seemed with this to be working for the very first run, but after that it constantly marked the password as needing a reset because whilst it updated the extension attributes it did not actually change the account password. Hence the extension attributes got out of sync with the actual password. I am now using the beta script for the first run only, and the original script for subsequent runs. I have set the interval to daily but even so it will take two or three days to see if this is working. I am still suspicious that it is going to keep marking the account as needing to be reset but again it will on subsequent runs update the extension attributes but fail to actually change the password. I will repeat the testing to see what happens. I presume that if the LAPS Reset attribute contains 'yes' then it indicates it needs to reset the password and thinks it is out of sync. Currently it is in sync - I have test both the account password and the keychain passwords and I have made sure this extension attribute is currently empty. |
@PezzaD84 What it failed to do is change the password for the local items keychain, or at least it has ended up with a password that does not work. For the local items keychain none of the original password, the rest set password, nor the second set password work. For the login keychain the second set password is working. It also ended up with the LAPS Reset Password extension attribute set to 'Yes' meaning that next time it runs it will reset the account. So, a couple of related faults there. This is with the first time run being the beta script and the subsequent runs being the released script. |
Thanks for the feedback and the logs. When the password is cycled the script is meant to delete the existing keychain and so a new one will be created at log in but clearly it's not clearing all the keychain items. I will have to do some more testing to see whats going wrong and where. |
@PezzaD84
However I get the impression that the dreaded local items keychain cannot be manipulated at all at least by the same security command. As I am sure you are aware the Login keychain is at ~/Library/Keychains/login.keychain.db and the local items keychain is at ~/Library/Keychains/[UUID]/keychain-2.db.* It would be preferable to preserve this keychain but for the LAPS account it is les important than a user account so if needed just deleting the local items keychain sub-folder would be ok. It could be Apple have changed things in new macOS versions but previously I used the LAPS solution here - https://github.com/NU-ITS/LAPSforMac When I last used it I do not recall it causing any keychain problems. It would therefore be worth having a look at its script. Be aware its code for reading and modifying its extension attribute is out of date, as an example its xpath command needs changing on Big Sur and later. You only need to look really at its code for changing the user/keychain passwords and see if it works better. |
@PezzaD84
I have recently joined an organisation with existing Macs and Jamf and currently existing local admin accounts all using the same password.
I am looking to implement your macOSLAPS solution and would like to use it to take over the existing local admin accounts. As they currently all have the same password it would in theory be possible to do either of the following.
It would seem that the first option would be preferable however it looks like your current setup is not geared up for this.
Clearly I could as per your documentation create a new (additional) local admin account but that is not desirable either. Do you have an existing approach for this or would it be possible to add a new additional option to allow this?
Note: As we are using Jamf Connect it would be responsible for creating the local admin account initially so it would exist before your script gets a chance to create it. It is potentially possible that the initial password as created via Jamf Connect would not be a specific chosen password but the FileVault Personal Recovery Key which Jamf Connect would have enabled and as per (other) Jamf settings escrowed to Jamf. It is possible to read this recovery key via the Jamf API so you could also potentially build this capability in. See - https://travellingtechguy.blog/jamf-connect-and-laps/
The text was updated successfully, but these errors were encountered: