Syed Jahanzaib – Personal Blog to Share Knowledge !

July 4, 2012

Howto power ON ESXi Guest machine using CLI & howto link it to the DUDE :)

Filed under: Mikrotik Related, VMware Related — Syed Jahanzaib / Pinochio~:) @ 10:08 AM

I recently developed a Centralized Network Monitoring System using Mikrotik’s base THE DUDE . It is an amazing free application through which you can completely monitor your network environment and can perform various task also using single screen via web or console. I added various advance monitoring probes , You can find its demo screenshot at following link.

https://aacable.wordpress.com/2012/07/02/the-dude-show-us-your-map-series/

I decided to upgrade it from simple networking monitoring system to monitoring+management system I was already using its tool menu through which I was able to do RDP to any target windows pc, or Shutdown / Power ON any PC on the map or run any custom script to restart service on specific server, but the problem was that guest machines on VMWARE ESXI 4.0 were not responding to WOL packets (Magic Packets to power ON machine over the network), I searched over the internet but couldn’t found any solution to this, so I made my own scripts to fulfill the task.

First you need to enable SSH on your vmware ESXi box, You can enables ssh by using following guide

https://aacable.wordpress.com/2012/07/04/howto-enable-ssh-in-vmware-esxi-4-0/

Once SSH is enabled, test it by using any ssh client , for example PUTTY.

After successful logged in to ESXi host using putty, we have to find the guest machine VM ID which we want to power on, use the following command to list all machines

vim-cmd vmsvc/getallvms

You will get result something like below, Look for the VMID of the machine you want to get,

Vmid       Name                                              File

112            vmserver1 – WSUS                     WSUS/WSUS.vmx
16              vmserver2 – Symantec             symantec/symantec.vmx
96             vmserver3 – SAMETIME         vmserver3/vmserver3.vmx

For example you want to power ON the vmware1 – WSUS machine having vmid 112 , use the below command

vim-cmd vmsvc/powen.on  112

Now we can use above command and wrap it in any script or batch file or link it with the DUDE tool menu

For example if you want to execute above command using PLINK (Which is used to execute command on remote ssh server using ssh tunnel) in any batch file, use the below command

\\dudepc\share\plink.exe -ssh -l root -pw zaibpass 10.0.0.1 “vim-cmd vmsvc/power.on 112”

If you want to link it to dude Tool menu, Follow below steps
Open DUDE console, from left menu, Goto TOOLS , Click on + sign to add Tool

Type: Executable
Name: Power ON ESXi Guess OS
Command:
\\dudepc\bin\plink.exe -ssh -l root -pw zaibpass 10.0.0.1 “vim-cmd vmsvc/power.on 112”

Click on OK to save , Now open your map, right click on your desired target (vm guest) and goto tools menu, and your new tool will be appearing there, click on it and the script will execute. Its recommended to test the command before putting it on any batch file or script.

Regard’s
Syed Jahanzaib

Howto Enable SSH in VMWARE ESXi 4.0

Filed under: VMware Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 9:16 AM

Today I was in need to execute some scripts on ESXi 4.0 server via remote to power ON the VM guest machine , but there is no menu to enable ssh  in ver 4.0, so I followed below steps to enable ssh on esxi 4.0
Free version of ESXi do have ssh service available but its disabled by default.

Goto your ESXI server, At the console , press ALT-F1 ,

Type unsupported in the console and then press Enter. The text typed will not be show over the screen, so be careful while typing ,  If you typed in unsupported correctly, you will see the password prompt.
Now Enter the password for the root login.

# You should then see the prompt of ~ #
Now we need to Edit the file inetd.conf in order to enable ssh service, Open it in vi editor

vi /etc/inetd.conf

Find the lines that begins with #ssh and remove the #
Then save the file.
by pressing ESC and type in :wq  ,

Once you’ve closed the vi editor, you can either restart the esxi server
OR
Restart the inetd process only by following steps.

To restart inetd run , we first need to find the pid of inetd process by following command

ps | grep inetd

The output of the above ps command will be something like

4886     4886     busybox          inetd

the process ID in this example is 4886. Now run

kill -HUP 4866 

Now try to login to your ESXI 4.0 via putty or any other ssh client, Hopefully It will work fine 🙂

Good thing about new ESXI 4.1 version is that it supported enabling SSH via main console, no need to go back to black screen, i mean cli.

http://www.ceyhunkirmizitas.net/vmware/tech-support-mode-has-been-disabled-by-the-administrator-on-esxi-4-1/
http ://www.youtube.com/watch?v=x1X29hOviBs

Regard’s
Syed Jahanzaib