I'm trying to start on .ova with VirtualBox and want to import the same image later in vSphere.
Ubuntu cloud images don't have a standard password anymore.
I'd like to edit the .ova to configure a password. (and later SSH keys)
The downloaded .ova does have a password property.
I found a tool called cot
(Common OVF tool) to edit the properties.
I tried:
cot edit-properties ubuntu-18.04-server-cloudimg-amd64-custom.ova -p password=ubuntu
Also also tried:
cot edit-properties ubuntu-18.04-server-cloudimg-amd64-custom.ova -p user-data="password: ubuntu"
Both attempts without success. (unable to login)
Is there a step to apply this configuration into the images, or do these properties get passed to the image when it starts?
Any ideas?
Updated: (answers to background questions)
- As a first step I want root access, so I can test the network setup of adapter, bridge, routes, DNS.
- A new user with ssh key and sudo is 2nd goal.
- Ubuntu 17.10 (soon 18.04)
- VirtualBox 5.2.14
- vSphere 5.5
Best Answer
Questions
It would be useful if you could add background information to the question, like:
General plan
Virtualbox
Cloud-Init
If you are using the Ubuntu Cloud Images, you should use Cloud-Init for setting the initial configuration, it allows you to set up:
... among other features.
Cloud-init's behavior can be configured via the user-data flag for inline commands or calling a YAML type config file with the settings to apply.
This is might be done via the
--user-data
or--user-data-file
argument when you are running inline, or you can do it with the ISO. I'm going to show the steps for the ISO mount mode.I will not setup a password for root or the user, I'm creating instead a new user with SSH access via ssh public keys and allowing the user sudo permissions instead.
Here is a sample user-data cloud-config file, create it with your text editor, and respect the name or the seed file won't be a valid seed and won't work.
You can also have a meta-data for the hostname and other definitions:
After creating the files generate an iso file to load as a cdrom or dvd from the virtual manager:
You need
genisoimage
for this or thecloud-utils
toolcloud-localds
for this other option:Remember that if you leave the seed / nocloud iso mounted, it will ovewrite the settings in the VM with those in the data files. And if you change anything in user-data or meta-data you need to rebuild the iso or img.
Boot
You can now boot the VM. By default, you can not ssh to the machine using the username and password or connect through the VNC console (the "graphical" VM window in Virtualbox). You have to use public / private key authentication method with ssh. This means enabling a user with a public ssh key in the user-data YAML file. Also, sudo privileges elevation for the ubuntu account is passwordless, but the account is locked by default.