By William Lam, Sr. Technical Marketing Engineer
For those of you who are familiar with the vCLI’s vifs utility, have probably used it to remotely upload/download files to a datastore located on a vSphere host. An example of this could be uploading a patch or an ISO image as seen in the screenshot below.
However, did you know you can use the vCLI’s vifs utility for more than just datastore file management? A recent question that came up was about updating the /etc/hosts file across several hundred vSphere hosts. One solution is to enable SSH access to the vSphere host and then use scp (secure copy) to upload the file, but you can also accomplish this using the vifs utility without needing to enable SSH access.
The vifs utility, in addition to providing datastore file management also provides an interface for manipulating files residing on a vSphere host. These interfaces are exposed as URLs:
that can be accessed using a web browser with standard GET/PUT operation as well as using the vifs utility. If you point your web browser to your vSphere host and append /host path, after providing your credentials, you should see the following list of files.
You will notice a variety of configuration and log files, some of which should look pretty familiar. To view the same list of files using the vifs utility, use the –dir option and specify /host as the path.
Going back to our use case, we can take a local host file that we created and remotely upload it to our vSphere host using the vifs utility. To so do, use the –put option and specify the local hosts file as well as the destination path which will be /host/hosts.
If you login to your vSphere host via SSH, you can confirm that the /etc/hosts file has now been updated with the contents you just uploaded.
Another common use case for vSphere administrators is replacing the default VMware self-signed SSL certificates with actual signed SSL certificates and this can can also be done using the vifs utility. Here is a screenshot on updating both the rui.crt and rui.key files.
One question you might be asking is why don’t I see all files under the /etc directory listed using vifs? The reason for this is that not all files listed are from /etc directory and some of the files are from other directories within the vSphere host. These files are actually “logically” presented under /host path which are then mapped back to their absolute filesystem path in the vSphere host. The presentation of these files and their respective permissions are controlled by the following configuration file: /etc/vmware/hostd/webAccessibleConfigFiles.xml
If we take a look at the file and using the SSL certificates as an example, we can see the following mapping:
/host/ssl_cert => /etc/vmware/ssl/rui.crt
/host/ssl_key => /etc/vmware/ssl/rui.key
We can also see there are different permissions on these files, you can perform a GET/PUT operation on the rui.crt file but only a PUT for rui.key. For the complete list of files and their permissions, please refer to the documentation here.
As you can see, you can now leverage vifs for both datastore file management as well as managing some of the common files found on your vSphere host.
Get notification of new blog postings and more by following lamw on Twitter: @lamw