VMware Cloud Community
utsavagarwal
Contributor
Contributor

useradd deprecated - commandline replacement?

Folks,

Moving to vsphere 5 - forced to use ESXi. Checking if someone faced this same problem.

~ # useradd monitor

***
*** The useradd command is deprecated: All user operations should be done via VI client or vim-cmd
***

How would I add a user/password in ESXi via an unattended script? I understand useradd still works, but I want to know it's commandline replacement since it's deprecated. Also, how would I set the passwd automated? There is no chpasswd in ESXi (unlile ESX).

0 Kudos
5 Replies
MartinAmaro
Expert
Expert

You can create users modify password and create groups with the vcenter client.

You can also do it via powershel or powercli using the New_VMHostAccount and Set-VMHostAccount

New-VMHostAccount -Id UserName -password Pa$$w0rd -Description "MyNewUser" -AssignGroups localadmin,root

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful.
utsavagarwal
Contributor
Contributor

Hi Martin, thanks for the response.

Using the gui client is not an option, since the process need to be scripted/automated.

Integrating powercli with our automation/build system is not a solution at this point.

The most generic way is to use the commandline to create the service account - before we can use the SDK remotely.

0 Kudos
MartinAmaro
Expert
Expert

Just try the command below and it worked, why don�t you give it a try

"useradd -M -s /sbin/nolong user" then you will have to update passwd, shadow and group entries in the etc directory.

Or check this How to Create Custom Roles on Standalone ESX(i) Host

http://www.virtuallyghetto.com/2011/06/how-to-create-custom-roles-on.html

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful.
0 Kudos
mcowger
Immortal
Immortal

Martin - we know the command works right now.  The problem is that its deprecated, meaning VMware can remove it at anytime without warning.

And the custom roles dont help, because roles apply to users, and users are what he needs to create.

I poked through vim-cmd last night, and couldn't find anything helpful.  I'd recommend filing a bug with VMware.

--Matt VCDX #52 blog.cowger.us
0 Kudos
MartinAmaro
Expert
Expert

Any reason why you must have local users and not go to enterprise level security and use something like AD and use host profiles to joing the host to AD and assign permissions based on users and groups??....

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful.
0 Kudos