XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    cloud-init ssh key works but not user config

    Scheduled Pinned Locked Moved Xen Orchestra
    8 Posts 4 Posters 2.3k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • patrikwmP Offline
      patrikwm
      last edited by

      Hi!

      Im have problems with cloud-init Custom config. SSH Key works but not Custom Config.

      1. Download focal-server-cloudimg-amd64.ova from
        https://cloud-images.ubuntu.com/focal/current/
      2. Import it in Xen Orchestra (xo-server 5.79.5, xo-web 5.82.0)
      3. Convert the imported ova vm to template.
      4. Create VM from the template with Install Settings "SSH Key" and my ssh key.
      5. VM boots and i can ssh to the machine with user: ubuntu and my SSH key.
      6. mount /dev/xvdb /mnt/ and copy /mnt/user-data
      #cloud-config
      hostname: ubuntu-focal-20.04-cloudimg
      ssh_authorized_keys:
        - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA....
      
      1. Create new VM from the template with Install Settings "User Config" and the config I copied from /mnt/user-data
      2. VM boots and i can NOT login with user: ubuntu and my SSH key.

      So what is missing from the User Config that is in the SSH Key cloud-init?

      Best regards,
      Patrik

      patrikwmP 1 Reply Last reply Reply Quote 0
      • patrikwmP Offline
        patrikwm @patrikwm
        last edited by

        Ok i figured it out. Seems like you need to have a valid or empty Network Config. When using the default commented out config it will not work. If i empty the Network Config field or uncomment all the lines it will work as expected.


        Following works

        User Config

        #cloud-config
        hostname: testmachine2
        ssh_authorized_keys:
          - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA...
        packages:
          - xe-guest-utilities
        

        Network Config

        network:
          version: 1
          config:
          - type: physical
            name: eth0
            subnets:
              - type: dhcp
        

        Following does not work

        User Config

        #cloud-config
        hostname: testmachine2
        ssh_authorized_keys:
          - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA...
        packages:
          - xe-guest-utilities
        

        Network Config

        #network:
        #  version: 1
        #  config:
        #  - type: physical
        #    name: eth0
        #    subnets:
        #      - type: dhcp
        
        1 Reply Last reply Reply Quote 0
        • olivierlambertO Offline
          olivierlambert Vates 🪐 Co-Founder CEO
          last edited by

          Hi!

          Thanks for the feedback. So I'm not sure to get it. If it's commented it doesn't work, but if it's empty, it does? That's weird 🤔

          ruskofdR 1 Reply Last reply Reply Quote 0
          • ruskofdR Offline
            ruskofd @olivierlambert
            last edited by

            I can confirm this behavior :

            • empty/generic network config (i.e basic DHCP) : OK
            • commented : not OK
            1 Reply Last reply Reply Quote 0
            • olivierlambertO Offline
              olivierlambert Vates 🪐 Co-Founder CEO
              last edited by

              Can you check the actual diff in the Cloud init disk? If empty, no network file?

              ruskofdR 1 Reply Last reply Reply Quote 0
              • ruskofdR Offline
                ruskofd @olivierlambert
                last edited by ruskofd

                Commented :

                1854ef12-2ffe-421e-8ced-cf83eccb03fb-image.png

                Empty :

                77700437-a51e-4b8f-80ec-f70ae9cab967-image.png

                Seems consistent imo.

                ruskofdR 1 Reply Last reply Reply Quote 0
                • ruskofdR Offline
                  ruskofd @ruskofd
                  last edited by

                  Regarding to logs on the machine where the network configuration is commented, there is this error : 2021-06-20 21:22:59,657 - util.py[WARNING]: Getting data from <class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloudNet'> failed

                  No other errors, but it seems sufficient to broke the provisionning.

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    ceoneezm_
                    last edited by

                    Hello,
                    Did you manage to make it work with a static addressing network ?
                    I tried this (where myip and mygateway are replaced by real values)

                    network:
                      version: 1
                      config:
                        - type: physical
                          name: eth0
                          subnets:
                            - type: static
                              address: myip/24
                              gateway: mygateway
                    

                    with no success.
                    and as I don't have an IP assignated and theses cloud images are passwordless by default I can't event log in from the console to troubleshoot.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post