Cloud init image - unable to login with key

Issues related to applications and software problems and general support
Post Reply
Posts: 2
Joined: 2020/05/20 12:26:25

Cloud init image - unable to login with key

Post by spock123 » 2020/05/20 12:47:53


using images from here (ec2, generic cloud) and terraform, I'm not able to get ssh key authentication working. When I change only image_id in terraform config to Ubuntu 18.04 / 20.04, everything is working as expected.
Seems like centos is ignoring all the user_data as well as basic provider info such as hostname.
I'm searching a couple of days, but it looks like I'm the only one with this issue.

Is there something specific that needs to be set?

My user-data config, although nothing special:

Code: Select all

package_upgrade: true
#fqdn: basic
  - name: vagrant
    lock_passwd: false
    gecos: Cloud User
    groups: wheel
    shell: /bin/bash
      - ssh-ed25519 key user@localhost.localdomain
hostname: basic
and corresponding part of

Code: Select all

resource "huaweicloudstack_blockstorage_volume_v2" "volume_1" {
  region      = "region"
  availability_zone = "az1.dc0"
  name        = "volume_1"
  description = "volume_1"
  size        = 10
  #image_id    = "143034d7-dddc-4a3e-bf37-6c9fd96e914d" #centos8
  #image_id  = "4ef76506-13cb-41ce-94d6-9cf523caf6b4" #centos7
  #image_id = "74d67359-e299-4383-b890-9de2ef633020" #ubuntu18.04
  #image_id = "84db7f7f-904b-4339-8def-8efb59dbf4be" # ubuntu 20.04
  image_id = "9febe918-1cc0-468b-a100-db456a7b7540" # centos8 generic
  #image_id = "354c12e3-2c21-4d04-852d-8be0a9153bd9" # centos8 ec2
  volume_type = "SSD01"

resource "huaweicloudstack_networking_port_v2" "port_1" {
  name               = "port_1"
  network_id         = "991212ae-73aa-4b00-a4eb-52ef71b3cc92"
  admin_state_up     = "true"
  #security_group_ids = []

  fixed_ip {
    subnet_id  = "20387e65-9794-4dbf-85d5-8844c169ffd8"
    ip_address = ""

resource "huaweicloudstack_compute_instance_v2" "testsrv" {
  name              = "basic-orig"
  flavor_name       = "s3.small.1"
  key_pair          = "authorized_keys"
  security_groups   = ["default", "base"]
  availability_zone = "az1.dc0"
  region            = "sk-ba-1"
  user_data         = file("user_data.yml")

  network {
    port =

  block_device {
    uuid                  =
    source_type           = "volume"
    destination_type      = "volume"
    boot_index            = 0
    delete_on_termination = true

Thank you for pointing me to right direction.

Posts: 2
Joined: 2020/05/20 12:26:25

Re: Cloud init image - unable to login with key

Post by spock123 » 2020/05/21 07:16:11

Quick solution - use config_drive: true within a instance

Reason: Without config_drive: true an instance is trying to get config from network. Builtin version of cloudinit in newest centos has bug:

Code: Select all

failed run of stage init                                                                 
Traceback (most recent call last):                                                       
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/", line 652, in status_wrapper                                                                                       
    ret = functor(name, args)                                                            
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/", line 362, in main_init  
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))               
  File "/usr/lib/python3.6/site-packages/cloudinit/", line 649, in apply_network_config                                                                                   
    netcfg, src = self._find_networking_config()                                         
  File "/usr/lib/python3.6/site-packages/cloudinit/", line 636, in _find_networking_config                                                                                
    if self.datasource and hasattr(self.datasource, 'network_config'):      
  File "/usr/lib/python3.6/site-packages/cloudinit/sources/", line 115, in network_config                                                                    
    self.network_json, known_macs=None)     
  File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/", line 645, in convert_net_json                                                                    
    'Unknown network_data link type: %s' % link['type'])                                 
ValueError: Unknown network_data link type: cascading
The newest centos has builtin version 18.5, but ubuntu has 20.1 and there is this bug solved, so cloudinit run without errors.

The reason why I was able to start instance manually through console is that huawei's openstack use configdrive module, not network. So the finding with cdrom was actually solution.

So there are two options:

1. Use config_drive: true openstack will generate cd drive and mount it into instance. Easy.
2. Update cloud-init in centos Start manually instance, get in, update cloud-init, make an image from instance and then use this new image. Harder.

Post Reply

Return to “CentOS 8 - General Support”