openstackdevstackopenstack-horizonopenstack-heat

Login password for ubuntu, RHEL, any cloud image


OpenStack cloud Images:

There are multiple cloud images which are available at https://docs.openstack.org/image-guide/obtain-images.html. In order to login to the VMs once those are deployed is either by using ssh key pair or password. But there are images where the sshkeypairlogin is disabled and there is no in-built password by default, then how to login to these VMs where the user have only information on the user-name


Solution

  • There are options to generate the password for the in-built users using cloud-init:

    Option-1: Using OpenStack horizon

    If the user is using horizon to launch the instance then for the post-configuration by providing the config as:

        #cloud-config
        chpasswd:
          list: |
            cloud-user:rhel
            root:rheladmin
          expire: False
    

    Here the passwords are generated for cloud-user and root users of RHEL image. The same is used for any user of any image simply by replacing the user.

    Option-2: Using OpenStack heat template

    Using the openstack heat template by providing the user-data as below:

    heat_template_version: 2015-04-30
    
    description: Launch the RHEL VM with a new password for cloud-user and root user
    
    resources:
      rhel_instance:
        type: OS::Nova::Server
        properties:
          name: 'demo_instance'
          image: '15548f32-fe27-449b-9c7d-9a113ad33778'
          flavor: 'm1.medium'
          availability_zone: zone1
          key_name: 'key1'
          networks:
          - network: '731ba722-68ba-4423-9e5a-a7677d5bdd2d'
          user_data_format: RAW
          user_data: |
            #cloud-config
            chpasswd:
              list: |
                cloud-user:rhel
                root:rheladmin
              expire: False
    

    Here the passwords are generated for cloud-user and root users of RHEL image. The same is used for any user of any image.