1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[Tutorial] How to reset ESXi v6 root password

Discussion in 'Cluster Computing' started by iGalin, Aug 25, 2016.

  1. #2
    Hello DP users,

    Hope this little tutorial on how to reset ESXi root password helps!!!
    Disclaimer: VMware doesn't suggest any other method but to reinstall the ESXi host!!! If you follow this tutorial - I'm not responsible for any/all possible damages!!!

    I used this version of ESXi to reset the password:
    ESXi ISO image (Includes VMware tools) 2016-03-15 | 6.0U2 |
    (VMware ESXi 6.0.0 VMKernel Release Build 3620759)

    You will need a physical access to ESXi host in order to be able to reset the password because you cannot shutdown/reboot(F12) without the password.
    Download Kali linux distribution, burn it and boot from it.

    ESXi stores passwords in /etc/shadow file and once the machine is down it's saved in state.tgz So we need to find it. It's usually either on sda5 or sda6:
    root@kali:~# fdisk -l
    You should see sda5 and sda6 partitions.
    Create the mounting points:
    root@kali:~# mkdir /mnt/sda5
    root@kali:~# mkdir /mnt/sda6

    Mount them:
    root@kali:~# mount /dev/sda5 /mnt/sda5
    root@kali:~# mount /dev/sda6 /mnt/sda6

    Look for state.tgz file
    root@kali:~# ls -l /mnt/sda5 | grep state
    in my case state.tgz file was on this partition, so I'm skipping sda6
    Copy this file to your home folder, extract it and edit the shadow file
    root@kali:~# cp /mnt/sda5/state.tgz state.tgz
    root@kali:~# gzip -d state.tgz
    root@kali:~# tar -xvf state.tar
    root@kali:~# gzip -d local.tgz
    root@kali:~# tar -xvf local.tar
    root@kali:~# cd /etc
    root@kali:/etc# vi shadow
    upload_2016-8-25_15-25-48.png

    make changes, save, exit and put it back:
    root@kali:/etc# cd ..
    root@kali:~# tar -czvf local.tgz etc
    root@kali:~# tar -czvf state.tgz local.tgz
    root@kali:~# cp state.tgz /mnt/sda5/state.tgz
    root@kali:~# umount /mnt/sda5
    root@kali:~# umount /mnt/sda6

    Once you reboot - you should be able to login without a password and set a new one
    upload_2016-8-25_15-26-9.png
    SEMrush
     
    Last edited: Aug 25, 2016
    iGalin, Aug 25, 2016 IP
    3SS, arghya139 and Dreamer05 like this.
    SEMrush
  2. davidearner

    davidearner Active Member

    Messages:
    274
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    90
    #3
    I'm planning to test few VMware for cryptomining. Will there be a possibility to lose the data if any step goes wrong? Nice article.
     
    davidearner, Aug 30, 2016 IP
  3. iGalin

    iGalin Member

    Messages:
    25
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    28
    #4
    Yes, there is always a risk, however in my experience all VMs stayed in tact
     
    iGalin, Aug 30, 2016 IP
    davidearner likes this.
  4. batchen

    batchen Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #5
    HELLO!
    PLEASE FIX YOUR POST AS WE MADE A MISTEAK CAUSE OF IT

    see you wrot after the extrectiong - >
    cd /etc
    and its not good!! as it making you go inside the LiveCD /etc make all changes there and then overiting esxi /etc with Livecd /etc!!

    the right step would be - cd etc with no / !!!

    PLEASE FIX IT!

    we have managed to fix this misteak by doing this steps- >


    its a command taypo issue - if you notice after extracting etc to root

    you did the command "cd /etc" instead of "cd etc"

    and as a result you copied the livecd /etc instead of the real esxi etc file and run over it!



    the solution :

    we had installed a new esxi 5.5 and started to copy what we did had left.



    so you need to do this steps :

    make new esxi 5.5

    go to etc there and make your own etc file - that means that yull see there more files then you need.

    make sure you have only this :

    checkconfig.db

    dhclient-vm0.leases

    hosts

    keymap

    random-seed

    resolve.conf

    security(file)

    sfcb(file)

    shadow

    ssh(file)

    vmsyslog.conf

    vmsyslog.conf.d(file)

    vmware(file)



    all other files you can remove.

    now you have to find the file onestage.tgz when you have livecd on mount all the disks that you see at fdisk -l ( the ones that you can mount , the vmfs you cant mount and it

    will apper as unknown"



    mount everything :

    mkdir /mnt/sda2

    mount /dev/sda2 /mnt/sda2



    mkdir /mnt/sda3

    mount /dev/sda3 /mnt/sda3



    mkdir /mnt/sda4

    mount /dev/sda4 /mnt/sda4



    mkdir /mnt/sda5

    mount /dev/sda5 /mnt/sda5



    and so on...

    and there you should have (dig in the files good!) a file name one(somthing).tgz

    im sorry i cant remmber the file name! but i think it onestage.tgz or somthing like that.

    take this file cp to root and extract -



    then, it will have /etc/ and /var/ inside of it - only part of /etc/

    but it will help you to fill up the files that you took from the new esxi 5.5 machine .

    checkconfig.db -dont touch anything

    dhclient-vm0.leases- you need to reconfigure the network you shuld have this info on onestage -> vmware file - esx.conf go inside and dig a little.

    hosts - should have this at onestage.tgz

    keymap- dont touch anything

    random-seed - dont touch anything

    resolve.conf-should have this at onestage.tgz

    security(file)- search here for the UUID file and change to the UUID as you have it in onestage.tgz , you should have a uuid file there to.

    sfcb(file)-search here for the UUID file and change to the UUID as you have it in onestage.tgz , you should have a uuid file there to - iwort it twice as i dont remmber in which file it was !

    shadow -> delete the string at the root user , thats why we have this all issue so dont forget!

    ssh(file)-dont touch anything

    vmsyslog.conf-dont touch anything

    vmsyslog.conf.d(file)

    vmware(file)- should have this at onestage.tgz

    just copy the esx.conf from onwstage to here it has all your privies configuration



    and after all that-

    rsync the new etc file to the LiveCd from the new esxi 5.5 with only the relevent files i wrote

    tar -czvf local.tgz etc

    tar -czvf state.tgz local.tgz

    cp state.tgz /mnt/sda5/state.tgz

    umount /mnt/sda5

    reboot



    Hope you will make it!!
     
    batchen, Jun 26, 2017 IP
  5. batchen

    batchen Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #6
    https://communities.vmware.com/message/2684615#2684615
     
    batchen, Jun 27, 2017 IP