Wednesday, May 13, 2015

how to change the root pass to a VM image in openstack

Why is this needed:  for example to setup the root pass of an existing image in glance without recreating it.

  1. setup the needed packages: 
    • apt-get install -y libguestfs-tool
  2. locate the image: mine is in /tmp/debian-8.0.0-openstack-amd64.qcow2 
  1. inspect the image to know what's the root disk partition: 
    • guestfish --rw -a /tmp/debian-8.0.0-openstack-amd64.qcow2
    • ><fs> run
    • ><fs> list-filesystems
    • /dev/sda1: ext3
  2. mount it in a dir: 
    • guestmount  -a /tmp/debian-8.0.0-openstack-amd64.qcow2  -m /dev/sda1 --rw /mnt/
  3. change the /etc/shadow file with the correct md5 crypted pass 
  4. unmount with:
    •  guestunmount  /mnt
  5. import into glance:
    • glance image-create --name="debian 8 amd64" --is-public=true --disk-format=qcow2 --container-format=bare < /tmp/debian-8.0.0-openstack-amd64.qcow2

1 comment:

  1. Hi Alex,
    it works on RPM based system too (just use yum install -y libguestfs-tool).

    Take care about md5, it is broken, you should move to sha512 (lots of stuff about how to migrate to sha512 on the web). Check the first field in the hash: it is a numerical number that tell's you the hashing algorithm that's being used.

    $1 = MD5 hashing algorithm.
    $2 =Blowfish Algorithm is in use.
    $2a=eksblowfish Algorithm
    $5 =SHA-256 Algorithm
    $6 =SHA-512 Algorithm

    To get a sha512 hash, run # grub-crypt --sha-512

    Cheers

    ReplyDelete