Default User and Password in Ubuntu Cloud Images

Backdoor

Ubuntu Cloud Images don’t have any password for the root or ubuntu users by default, relying only on using ssh keys. It is convenient for many tenants to just having a user and a password to log in rather than only a ssh key.

This is how to set a password for the ubuntu user:

1. Download the image:

$ wget http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img

2. Download backdoor-image:

$ bzr branch lp:~smoser/+junk/backdoor-image

3. Set the user and password:

$ sh backdoor-image --user ubuntu --password ubuntu --password-auth ubuntu-12.04-server-cloudimg-amd64-disk1.img

Now we can deploy the image, for example in our OpenStack infrastructure, and we can ssh into it with ubuntu as user and password or we can login via the console.

About these ads

6 thoughts on “Default User and Password in Ubuntu Cloud Images

  1. backdoor-image: line 1: syntax error near unexpected token `newline’
    backdoor-image: line 1: `’
    this is the error i have been getting, i dont think the backdoor-image was able to set the password and the username, am working on rhel 6.5 btw

  2. root@ubuntu01:~# sh backdoor-image –user ubuntu –password ubuntu –password-auth ubuntu-12.04-server-cloudimg-amd64-disk1.img
    backdoor-image: 2: backdoor-image: Syntax error: newline unexpected

    same error with ubuntu .. is there a workaround ?

    • Thanks for the comment. That’s right, it should have the same effect as long as cloud-init is executed and retrieves the settings from the metadata service.

      Sometimes, for example when troubleshooting the metadata service itself, backdoor-image comes very handy. The backdoor-image script was developed by smoser, author of cloud-init.

      • I think it’s better ti use image like CirrOS https://launchpad.net/cirros to troubleshoot where the user ‘cirros’ is set with the password ‘cubswin:)’
        In my opinion, Ubuntu UEC image are build to be use in production and if you need to set a password for a user you can use cloyud-init script like odyssey4me proposed. I’ve also a cloud-init script for that (create user ‘user’ with password ‘user’ and authorize ssh login through password). But the odyssey4me’s script is clearer and more efficient (@odyssey4me: thanks for that tip):
        #cloud-config
        groups:
        – user
        # Add users user with password user
        users:
        – default
        – name: user
        gecos: Foo User
        primary-group: user
        groups: admin
        plain_text_passwd: ‘user’
        sudo: ALL=(ALL) NOPASSWD:ALL
        lock-passwd: false
        # Authorize password authentication for SSH
        runcmd:
        – [ sh, -xc, “sed -i ‘s/PasswordAuthentication no/PasswordAuthentication yes/’ /etc/ssh/sshd_config” ]
        – [ sh, -xc, “service ssh restart” ]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s