Skip to content

Resetting Ubuntu VM Password does not work #8767

Closed

Description

@nxsbi
ISSUE TYPE
  • Other
COMPONENT NAME
UI
CLOUDSTACK VERSION
4.17.0
CONFIGURATION

NA

OS / ENVIRONMENT

Ubuntu 22.04 Server LTS (VM OS)

SUMMARY

I want to enable the Change Password functionality for Ubuntu based VM. I have a newly created Ubuntu 22.04 Server Template. I enabled the root user as well, and followed steps in https://docs.cloudstack.apache.org/en/latest/adminguide/templates/_password.html

However, for Ubuntu I cannot get it to work. Step 5 is not possible on Ubuntu so tried
update-rc.d cloud-set-guest-password defaults

Even after trying the Change Password from Cloudstack UI, the password does not change and my old password which I used while creating template still works.

These steps worked fine for CentOS, but not working for Ubuntu

STEPS TO REPRODUCE
Create a Ubuntu Template
Follow the cloud-set-guest-password steps - https://docs.cloudstack.apache.org/en/latest/adminguide/templates/_password.html
Create a new VM from this template, - New password that pops up does not work
Chnage password does not work from Cloudstack UI 

EXPECTED RESULTS
Password works
ACTUAL RESULTS
Password does not work. 

Activity

  1. nxsbi commented on Mar 9, 2024

    @nxsbi
    Author

    PS - I have also followed the steps in this link

    https://docs.cloudstack.apache.org/en/latest/adminguide/templates/_cloud_init.html#linux-with-cloud-init

    Created the files

    • /etc/cloud/cloud.cfg.d/99_cloudstack.cfg
    • /etc/cloud/cloud.cfg.d/80_user.cfg

    It still does not work.

  2. kiranchavala commented on Mar 11, 2024

    @kiranchavala
    Member

    @nxsbi

    Have you enabled the password option on the template

    Screenshot 2024-03-11 at 12 27 33 PM

  3. kiranchavala commented on Mar 11, 2024

    @kiranchavala
    Member

    @nxsbi

    could you please try with the following configuration

    cat /etc/cloud/cloud.cfg

    datasource_list: ["CloudStack"]
    
    datasource:
      CloudStack:
        max_wait: 60
        timeout: 30
    
    network:
      config: disabled
    
    users:
      - default
    
    system_info:
      default_user:
        name: root
    
    disable_root: false
    
    ssh_deletekeys: true
    
    cloud_init_modules:
     - seed_random
     - bootcmd
     - write-files
     - growpart
     - resizefs
     - disk_setup
     - mounts
     - set_hostname
     - update_hostname
     - update_etc_hosts
     - ssh
     - users-groups
    
    cloud_config_modules:
     - ssh-import-id
     - locale
     - [ set-passwords, always ]
     - ntp
     - timezone
     - disable-ec2-metadata
     - runcmd
    
    cloud_final_modules:
     - scripts-vendor
     - scripts-per-once
     - scripts-per-boot
     - scripts-per-instance
     - scripts-user
     - puppet
    
    warnings:
      dsid_missing_source: off
    
  4. weizhouapache commented on Mar 11, 2024

    @weizhouapache
    Member

    @nxsbi
    if you run the script cloud-set-guest-password manually inside the VM, is the password changed ?

  5. nxsbi commented on Mar 11, 2024

    @nxsbi
    Author

    @kiranchavala Yes - the password enabled is selected.
    Also tried the config you provided, but still not working

    @weizhouapache - I tried running the cloud-set-guest-password manually, and it produces errors -- and then it hangs - never gives the shell back (have to Ctrl+C)

    image
  6. weizhouapache commented on Mar 11, 2024

    @weizhouapache
    Member

    @kiranchavala Yes - the password enabled is selected. Also tried the config you provided, but still not working

    @weizhouapache - I tried running the cloud-set-guest-password manually, and it produces errors -- and then it hangs - never gives the shell back (have to Ctrl+C)

    @nxsbi
    try this script

    https://raw.githubusercontent.com/apache/cloudstack/main/setup/bindir/cloud-set-guest-sshkey-password-userdata-configdrive.in

  7. nxsbi commented on Mar 11, 2024

    @nxsbi
    Author

    @weizhouapache Thanks - I ran the script below is the output. Also tried resetting the password from UI after that but did not work.

    image
  8. weizhouapache commented on Mar 11, 2024

    @weizhouapache
    Member

    @weizhouapache Thanks - I ran the script below is the output. Also tried resetting the password from UI after that but did not work.

    image

    @nxsbi
    the output of the command looks ok to me.
    if you change the password of a non-root user, you need to change the username in the script.

  9. nxsbi commented on Mar 12, 2024

    @nxsbi
    Author

    Yes already did that - the username was changes to correct one. I have that working on my CentOS and Rocky Linux scripts so familair with that.

    I am walking through all steps -- Questions:

  10. weizhouapache commented on Mar 12, 2024

    @weizhouapache
    Member

    Yes already did that - the username was changes to correct one. I have that working on my CentOS and Rocky Linux scripts so familair with that.

    I am walking through all steps -- Questions:

    @nxsbi
    the doc is out of date

    if the password has been changed when you run the script manually - it means the script works.
    if so, you can create a systemd service for the script and auto-start it on startup.

  11. nxsbi commented on Mar 12, 2024

    @nxsbi
    Author

    @weizhouapache If I run the script manually, it gives an error. Where does it log the output?

    image

  12. nxsbi commented on Mar 12, 2024

    @nxsbi
    Author

    I believe I found the problem and the solution. Documenting below for others for future reference.

    Since my prior experience creating template revolved around CentOS/Rocky, I followed the steps shown in https://docs.cloudstack.apache.org/en/latest/adminguide/templates/_password.html (I had this URL saved from before)

    However, I determined that was not the right place for Ubuntu...

    Correct steps:

    I believe I was having issues earlier because I had followed both - "Adding Password Management" and "Cloud-Init Integration". And somehow those were conflicting.

    NOTE 2 - If you are adding Password Management, one of the step is to add the "Specify the managed user" during Cloud Init Setup and create the /etc/cloud/cloud.cfg.d/80_user.cfg. In this step, I had to modify the below line. Reason was that in the instance when I tried to do sudo command, I always kept getting error about the ". Changing to the new line fixes this for me (only tested in Ubuntu 22.04 Server LTS.)

    Original
    sudo: [\"ALL=(ALL) ALL\"] # User permissions
    New
    sudo: [ALL=(ALL) ALL] # User permissions

  13. added this to the unplanned milestone on Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions