Add a local vSphere ESXi user without using the vSphere GUI

So while hacking away at a demo I wanted to create a local user on my vSphere ESXi box, and got frustrated that according to all the documentation out there I had to use the vSphere GUI (or vicfg) to create one. Logged on locally to the ESXi box I wondered why the normal “adduser” command wasn’t available, but it turns out it actually is.

vSphere ESXi utilizes a binary called “busybox” for a lot of standard linux commands, as you can see if you look at the linked binaries in /bin:

~ # ls -l /bin/
<snip>
lrwxrwxrwx 1 root root 35 Apr 9 21:41 stty -> /usr/lib/vmware/busybox/bin/busybox
lrwxrwxrwx 1 root root 35 Apr 9 21:41 sum -> /usr/lib/vmware/busybox/bin/busybox
-r-xr-xr-x 1 root root 3432 Feb 22 01:27 summarize-dvfilter
lrwxrwxrwx 1 root root 35 Apr 9 21:41 sync -> /usr/lib/vmware/busybox/bin/busybox
lrwxrwxrwx 1 root root 35 Apr 9 21:41 tail -> /usr/lib/vmware/busybox/bin/busybox
lrwxrwxrwx 1 root root 35 Apr 9 21:41 tar -> /usr/lib/vmware/busybox/bin/busybox
<snip>

However, “adduser” isn’t there, but it is in the busybox binary itself. To use this command, simply call “busybox” with “adduser” as a parameter, and then the normal “adduser” parameters after that, like this:

~ # /usr/lib/vmware/busybox/bin/busybox adduser
BusyBox v1.20.2 (2012-12-11 11:54:28 PST) multi-call binary.

Usage: adduser [OPTIONS] USER

Add a user

 -h DIR Home directory
 -g GECOS GECOS field
 -s SHELL Login shell
 -G GRP Add user to existing group
 -S Create a system user
 -D Don't assign a password
 -H Don't create home directory
 -u UID User id

So, if you wanted to create the user “jonas” as a member of the root group with “/” as home directory and with “/bin/sh” as shell you could simply do this:

~ # /usr/lib/vmware/busybox/bin/busybox adduser -s /bin/sh -G root -h / jonas

About Jonas Rosland

Developer Advocate at EMC {code}
This entry was posted in How to, Installation, VMware, vSphere5. Bookmark the permalink.

One Response to Add a local vSphere ESXi user without using the vSphere GUI

  1. Pingback: How to Create New User in ESXi With Shell Script | DoubleCloud => Private Cloud + Public Cloud

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s