Enable root user on an deployed host

Hi,

When I do a deloy of a host with Maas. The maas server creates a user Ubuntu and disables the user root.

When I try to login via SSH to that deployed hosts with the user root. I get the error message: “Please login as the user “ubuntu” rather than the user “root”.” This is becource cloud-init has the setting disable_root set on false.

Can I set the disable_root to true, so that after a deployment of the host I can login with ssh via the Root user.

I’m trying to install an OpenStack environment with a Maas server. I’m using Openstack-ansible playbook to install the openstack. But the Openstack-ansible requires root for the targets.

The solution for this is:

  1. disable the setting disable_root, but where to do that.
  2. overwrite the /root/.ssh/authorized_keys with curtin

What is the best solution and how to solve it?

I have tryed overwriting the /root/.ssh/authorized_keys with curtin. But after I did a deploy this file got overwritten by Maas.

And I can’t find where to set the disable_root setting?

I find a little hack on my problem.

In the /etc/maas/preseeds/curtin_userdata file in the late_commands I add the following line:

activate_root: [ “curtin”, “in-target”, “–”, “sh”, “-c”, “sed -i ‘s/disable_root: true/disable_root: false/’ /etc/cloud/cloud.cfg”]

This sets disable_root in the correct setting

1 Like

Hi there,

The way we recommend customizing your deployments is via cloud-init or via curtin preseeds as you have done in your example (You can find more information in Customizing MAAS deployments with cloud-init).

However, a more elegant way of doing so is via cloud-init user-data
( see https://cloudinit.readthedocs.io/en/latest/topics/examples.html?highlight=users#including-users-and-groups )

You can pass user-data every time you deploy a machine via the API, or you can tell curtin to write cloud-init user-data on the installed system so it is executed on first boot. e.g in /etc/maas/curtin_userdata, you could add something like:

write_files:
  setup_user:
    path: /etc/cloud/cloud.cfg.d/99_setup_user.cfg
    content: |
      #cloud-config
      <your-user-data>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.