Having said that, there is a small caveat to this solution in which the credentials used to join the ESX(i) host must be exposed in clear-text, this may or may not be acceptable. A potential way of getting this to work is to create a dedicated windows service account with limited privileges to add only ESXi hosts to your domain.
The reason for the use of clear-text password is the vSphere API method that is used to join an ESX(i) host to AD domain, joinDomain(), only supports plain text.
Ideally, the password parameter should accept either an encrypted hash or some type of certificate which can be validated by Active Directory server. The actual solution is pretty straight forward, by crafting the appropriate call to vSphere MOB, we are able to generate a python script during the %firstboot section of ESX(i) kickstart installation which will execute upon the initial boot up of the host.
Update (03/26/11): Thanks to VMTN user klich who has found a solution to embed the password of the Active Directory user in a base64 encoding so that it is not visible in plain text for anyone who has access to the kickstart configuration file. To create the encoded hash, you will need access to either a ESX(i) or UNIX/Linux system which has python interpreter installed.
You will need to run the following command and substitute the password you wish to encode.
python -c "import base64; print base64.b64encode('MySuperSecurePasswordYo')"
The output will be your encoded hash:
Note: Make sure your ESX(i) hostname is configured with a FQDN (Fully Qualified Domain Name), else you will get an error when trying to join to AD domain.
The following snippet should be added to your %firstboot section of your kickstart. Remember to replace the variables: domainname, ad_username and encodedpassword with your configurations and make sure to leave the password variable blank.
ESX(i) 4.1
If you are using ESX(i) 4.1 Update 1 or if you run into the "urllib2.HTTPError: HTTP Error 403: Forbidden: Possible Cross-Site Request Forgery" you will need to use the following snippet below which includes the session cookie as part of the request to the vSphere MOB due to a recent CSRF patch from VMware identified by VMTN user klitch.
As a side note, it is quite unfortunate that ESXi only supports Microsoft Active Directory and does not integrate with other well known directory services such as NIS/NIS+, Kerberos, OpenLDAP, eDirectory, etc; this was actually possible with classic ESX. VMware has continued to focus on Windows-centric solutions and neglect the UNIX/Linux community by not supporting OS agnostic management tools that integrate with their vSphere platform. I hope this will change in the future for true interoperability.











Will -
ReplyDeleteGreat post, as always! Is there a way to encrypt the AD Admin password? This would most likely be important in some enterprises where the ESXi admin is not allowed to see the AD admin secrets.
Dave
Dave,
ReplyDeleteThe issue is the vSphere method only supports clear text. This means even if you encrypted the password, during the kickstart you still had to decrypt it and if the vSphere admins had access to the ks.cfg, they could easily figure out the password. I was thinking about something like that but I couldn't come up with anything that wouldn't allow someone to easily reverse engineer it. The limitation is with VMware only supported clear text, ideally an encrypted hash or certificate would be a better approach
Thanks Will for this script. I added it to my esxi kickstart but it doesn't seem to run. However if I run it manually on the host it works.
ReplyDeleteAny ideas?
It is part of my %firstboot.
Thanks Again
Jason
@jasgrif11,
ReplyDeleteHave you taken a look at vSphere Client while this is occurring to see what errors it is throwing?