Scandals of an ITian

Not just another Wordpress Site

Enabling SSH and SNMP on your ESXI 4, Vsphere

There are two ways to go about with this depending upon your installation

a. If your esxi installation is new and/ or your evaluation license is still valid, then go to the section that says Enable       SNMP via RCLI

b. If your esxi installation has been in production for a while / and or you got a license installed and your evaluation period has expired then go to the following section which is to enable SNMP via SSH. For this you will need to enable SSH first on your esxi host by following the steps detailed below.

Enabling SSH on your ESXI host.

  1. Shutdown all your running VM’s on the esxi host and place the host on Maintenance mode.
  2. Log onto your Esxi Console physically from the box by pressing F2
  3. Type in your root password
  4. Press ALT+ F1 to enter the Technical Support login. Beware that any changes from here will not be warranted for support with VMware. So please be careful and test this and practice on a test esxi host before going live with production.
  5. Type unsupported and press enter
  6. Type in your root password
    at the prompt again and press enter
  7. Now you need to edit the inetd.conf file. To do this type vi /etc/inetd.conf
  8. Scroll down using your down arrow key sort of towards the end of the screen where you would see two lines starting with #ssh. Place the cursor on top of the # and press delete. Do this for the next line as well.
  9. Now press SHIFT+: and type wq to save the file.
  10. Now you will be back at your #prompt. To restart the service type services.sh restart.
  11. Press ALT+F1 to return to the esxi host console page.
  12. Press ESC to log off
  13. Press F12 to initiate your restart of the esxi host.
  14. You will be promoted for your root password and press enter.
  15. Press F11 to restart the host.
  16. Once the esxi host is up and running again use your favourite SSH client mine is Putty and WinSCP to test SSH connectivity to your esxi host.

Enabling SNMP via SSH on your ESXI host.

  1. Once you got SSH running , download and install WinSCP on your workstation..
  2. Open WinSCP and type in the details for your esxi host including IP address, root as the username and root password. Make sure you change connection type to SCP from default SFTP option as shown

  3. Once logged in your WinSCP window will look like the follow. On the Esxi host side navigate to /etc/vmware and find the file called snmp.xml

  4. Drag and drop the snmp.xml file from the right to the left of the screen.

  5. Open the document with your favourite Notepad editor. I am using Notepad++

  6. It would have the following default settings:

  7. First and foremost make a copy of the file before editing it and save it with a different file name so that if something goes wrong you always have a copy of the original.
  8. Now do the following editing to it and save it with same file name snmp.xml.


  9. Save the file and now go back to WinSCP and drag the file from the left to the right and accept the warning message to overwrite the file

  10. Once that is done restart your esxi host and test SNMP which will be followed up in the next section.

Enabling SNMP via RCLI ( Only works for New Installation of Esxi , Valuation License still valid state)

  1. Download the Remote Command Line Interface from Vmware RCLI Download for Vsphere.
  2. Install it on your workstation.
  3. To start RCLI browse to your VMware folder under all programs and kick start the command line under vmware

  4. At the command prompt type cd bin and then do a dir. This Directory has all the scripts that are required to run a variety of tasks on your esxi and esx servers.
  5. Type the following command

    vicfg-snmp.pl –server ESXISERVERIP -c SNMPCOMMUNITYSTRING -t MONITORINGSERVERIP@162_or_161/SNMPCOMMUNITYSTRING

  6. To enable SNMP type vicfg-snmp.pl –server ESXISERVERIP –E
  7. To show the running config of SNMP on your esxi server type vicfg-snmp.pl –server ESXISERVERIP –s
  8. To test the SNMP confi type vicfg-snmp –server ESXISERVERIP –T

As you may have seen in the heading of this section this works only for new installation of esxi or those that have their Valuation license still valid (60 Days). For those who don’t fall into the category the only option is to go with SSH and then enabling SNMP option.

You will see this error if you try via RCLI

This is because remote write permission is disabled on the free version of esxi.

Now user your favourite SNMP monitoring station Cacti, Zenoss, Spiceworks there are so many to start monitoring your Esxi environment.

Next post update on this will be to check on Cacti monitoring these ladies

I would really appreciate some feedback for this article as to if this can be done in a simpler way or if there is a way to hack the write permission issue for the free esxi hosts.

Cheers

No related posts.

, , , , , , ,

  • Pingback: Enabling SSH and SNMP on your ESXI 4, Vsphere | scandals of an ITian

  • Pingback: Aben Samuel

  • Pingback: zenoss

  • Pingback: Ryan Trauntvein

  • Pingback: CaptainTweet

  • Pingback: Stephan Hadan

  • Pingback: Tweets that mention Enabling SSH and SNMP on your ESXI 4, Vsphere | scandals of an ITian -- Topsy.com

  • John

    Is it possible to monitor your ESXI using nagios with this method?

  • John

    Is it possible to monitor your ESXI using nagios with this method?

  • MG

    Good work.
    But, we need an agent that sends traps by snmp when an hardware event occurs, no?
    What do I get with SNMP without agent that detects hardware errors?

    Regards

  • MG

    Good work.
    But, we need an agent that sends traps by snmp when an hardware event occurs, no?
    What do I get with SNMP without agent that detects hardware errors?

    Regards

  • Pingback: Aben Samuel

  • Mike Hamilton

    Thank you for posting this – it really helped me get that enabled quickly.

  • Pingback: Aben Samuel

  • Pingback: Aben Samuel

  • Mike Hamilton

    Thank you for posting this – it really helped me get that enabled quickly.

  • Miker007

    Hi, when publish you the next Tutorial for Cacti / Zabbix for ESXi :)

  • Miker007

    Hi, when publish you the next Tutorial for Cacti / Zabbix for ESXi :)

  • MLohr

    Hey,
    i got this error:
    —————————————–
    C:Program Files (x86)VMwareVMware vSphere CLIbin>vicfg-snmp.pl -server -c SNMP_public -t @161/SNMP_public

    Enter username: root
    Enter password:
    Error: Server version unavailable at ‘https://localhost/sdk/vimService.wsdl’

    C:Program Files (x86)VMwareVMware vSphere CLIbin>
    —————————————–

    What can I do now? I am lost now…. ;- ( Pleas help me…

  • MLohr

    Hey,
    i got this error:
    —————————————–
    C:Program Files (x86)VMwareVMware vSphere CLIbin>vicfg-snmp.pl -server <IP-server> -c SNMP<some other chars>_public -t <IP-client>@161/SNMP<some other chars>_public

    Enter username: root
    Enter password:
    Error: Server version unavailable at 'https://localhost/sdk/vimService.wsdl&#39;

    C:Program Files (x86)VMwareVMware vSphere CLIbin>
    —————————————–

    What can I do now? I am lost now…. ;- ( Pleas help me…

  • rd355

    SNMP: For the free ESXi versions you can temporarily remove the key you’ve entered and then enable SNMP via vcfg-snmp.pl commands.

    SSH: We have a lot of ESXi (free) servers in our environment and I have been looking for an easier way to enable SSH. I am by no means a linux user let alone a guru, but after a lot of searching and a little bit of testing, you could use the following command right from the main prompt:

    cat /etc/inetd.conf | sed ‘s/#ssh/ssh/g’ > tmp && mv tmp /etc/inetd.conf

    Or if you prefer to create your own shell script .sh so you do not make a mistake (typo), you can do so and upload it to the local datastore. Once you have the script on your datastore, you’ll still need to log into the ‘Unsupported’ mode, but you can execute the shell script with the following command:

    ./vmfs/volumes/datastore1/.sh

    To create a shell script:
    – Open notepad
    – Copy and paste the command:
    cat /etc/inetd.conf | sed ‘s/#ssh/ssh/g’ > tmp && mv tmp /etc/inetd.conf
    – Save file with the .sh extension

    Hope this helps someone else

    • rd355

      **minor correction**

      to execute the script as posted you will need to be in the datastore1 directory:
      cd /vmfs/volumes/datastore1

      then you can type out:
      ./.sh

      OR

      If you use “/etc/tmp” instead of just “tmp” you could execute the script from initial prompt:
      cat /etc/inetd.conf | sed ‘s/#ssh/ssh/g’ > /etc/tmp && mv /ect/tmp /etc/inetd.conf

    • marvin

      How can you temporarily remove the key?

  • rd355

    SNMP: For the free ESXi versions you can temporarily remove the key you've entered and then enable SNMP via vcfg-snmp.pl commands.

    SSH: We have a lot of ESXi (free) servers in our environment and I have been looking for an easier way to enable SSH. I am by no means a linux user let alone a guru, but after a lot of searching and a little bit of testing, you could use the following command right from the main prompt:

    cat /etc/inetd.conf | sed 's/#ssh/ssh/g' > tmp && mv tmp /etc/inetd.conf

    Or if you prefer to create your own shell script <filename>.sh so you do not make a mistake (typo), you can do so and upload it to the local datastore. Once you have the script on your datastore, you'll still need to log into the 'Unsupported' mode, but you can execute the shell script with the following command:

    ./vmfs/volumes/datastore1/<filename>.sh

    To create a shell script:
    – Open notepad
    – Copy and paste the command:
    cat /etc/inetd.conf | sed 's/#ssh/ssh/g' > tmp && mv tmp /etc/inetd.conf
    – Save file with the .sh extension

    Hope this helps someone else

  • rd355

    **minor correction**

    to execute the script as posted you will need to be in the datastore1 directory:
    cd /vmfs/volumes/datastore1

    then you can type out:
    ./<filename>.sh

    OR

    If you use “/etc/tmp” instead of just “tmp” you could execute the script from initial prompt:
    cat /etc/inetd.conf | sed 's/#ssh/ssh/g' > /etc/tmp && mv /ect/tmp /etc/inetd.conf

  • Pingback: david.huang

  • Pingback: onion_soup

  • Pingback: Gabrie

  • Cezar Lica

    instead of rebooting the host, you will run “services.sh restart” (ssh root@esx4.1.host).
    after this, you need to reconnect that host to your central management server.

  • Cezar Lica

    instead of rebooting the host, you will run “services.sh restart” (ssh root@esx4.1.host).
    after this, you need to reconnect that host to your central management server.

  • Jonathan Puddle

    Thanks, worked like a charm!

  • Jonathan Puddle

    Thanks, worked like a charm!

  • Pingback: Matt Simmons

  • Pingback: Aben Samuel

  • http://twitter.com/bizzyunderscore Matt Ghali

    you don’t need to restart all services, at least in esxi 4.1. all you need to run is:
    /etc/init.d/hostd restart

  • http://twitter.com/bizzyunderscore Matt Ghali

    also, simply editing snmp.xml on esxi is probably a lot easier than scping it back and forth :)

  • Many

    Works great for me on ESXi 4.1 free license,,, but I cannot see the volumes via SNMP,, I can see only the NICs :-(