Home Virtualization Using Session Files for ESXi Host Authentication from vMA and vCLI

Using Session Files for ESXi Host Authentication from vMA and vCLI

by admin

I’ve posted a number of articles on vMA administration in the course of writing about the VCAP5-DCA objectives, including information on configuring fast path authentication, however I didn’t spend a lot of time talking about session files. Session files can be used to store ESXi host user credentials, and can be called when running commands against ESXi hosts, removing the need to include a username and password when executing a command.

To create session file, we need to use the save_session.pl script which can be found in /usr/lib/vmware-vcli/apps/session on the vMA. The script has a useful help file, accessed in the usual way:

./save_session.pl --help

The required parameters for creating a session file are the target host, the username and password, and the location to save the session file to. For example:

./save_session.pl --server 192.168.88.134 --user name -root -password Pa55w0rd -savesessionfile /home/vi-admin/esx1-session

I now have a file called ‘esx1-session’. This can be called when running, for example, a vicfg-* command against a host:

vi-admin@vma:/usr/lib/vmware-vcli/apps/session> vicfg-nics -l --sessionfile ~/esx1-session
Name    PCI     Driver     Link Speed    Duplex MAC Address        MTU    Description
vmnic0  02:00.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:9c  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic1  02:01.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:a6  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic2  02:03.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:b0  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic3  02:04.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:ba  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic4  02:05.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:c4  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic5  02:06.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:ce  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic6  02:07.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:d8  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic7  02:08.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:e2  1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic8  02:09.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:ec         Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic9  02:0a.0 e1000      Up   1000Mbps Full   00:0c:29:6f:56:f6         Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

Though the examples I’ve shown in this article are from a vMA, you will likely get most use from session files when using vCLI installed on a Windows system, where fast pass isn’t an option. On windows the save_session script can be found in C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\session, and works in the same way as shown above.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More