Linux, 工作, 生活, 家人

Cloud, Ubuntu

Change Ubuntu Cloud Image Password

Ubuntu cloud image is very good for deploy a simple qemu image system.
But the image has it owns password and initial script.

If want to use it, it needs to add new username and password into it.
and remove some packages.Download cloud Image from ubuntu, ex: download Ubuntu Zesty Cloud Image

wget https://cloud-images.ubuntu.com/zesty/current/zesty-server-cloudimg-arm64.img 

If locate in Taiwan, there is Taiwan mirror site,http://ftp.yzu.edu.tw/Linux/ubuntu-cloud-images/, it would be fast then cloud-images.ubuntu.com

wget http://ftp.yzu.edu.tw/Linux/ubuntu-cloud-images/zesty/current/zesty-server-cloudimg-arm64.img

Zesty only has UEFI image, so, there is no -disk1 or -uefi postfix keyword.

If used bionic (Ubuntu 18.04), if you found change password function doesn’t work.
Please shutdown this image (suppose run with QEMU) and run change password command again .

Suppose that something modify password when booting on Ubuntu 18.04.

Install backdoor-image package, this program can help to install new username and password into cloud image.

apt install bzr qemu-utils  
bzr branch lp:~smoser/+junk/backdoor-image
sudo apt-get install -qy cloud-image-utils git
git clone https://gist.github.com/8c65b8771d5ab1d99c44c285323dfff6.git backdoor-image

Add new password, but first account is not work for me most time, so, I would like to add new username and password. (note: please don’t use this as default password on business purpose. )

cd backdoor-image  
sudo ./backdoor-image --user ubuntu --password ubuntu --password-auth ../zesty-server-cloudimg-arm64.img 
sudo ./backdoor-image --user test --password 123456 --password-auth ../zesty-server-cloudimg-arm64.img 

After boot into virtual machine with this image, it can remove unnecessary packages.

sudo apt remove cloud-initramfs-copymods cloud-init

發佈留言