root-password-generate=on Generate a new root password for the VM. When used, virt-install will print the generated password to the console, and pause for 10 seconds to give the user a chance to notice it and copy it.
disable=on Disable cloud-init in the VM for subsequent boots. Without this, cloud-init may reset auth on each boot.
root-password-file= A file used to set the VM root password from. This option can be used either as "root-password-file=/path/to/password-file" or as "root-password-file=/dev/fd/n", being n the file descriptor of the password-file. Note that only the first line of the file will be considered, including any whitespace characters and excluding new-line.
meta-data= Specify a cloud-init meta-data file to add directly to the iso. All other meta-data configuration options on the --cloud-init command line are ignored.
user-data= Specify a cloud-init user-data file to add directly to the iso. All other user-data configuration options on the --cloud-init command line are ignored.
root-ssh-key= Specify a public key to inject into the guest, providing ssh access to the root account. Example: root-ssh-key=/home/user/.ssh/id_rsa.pub
clouduser-ssh-key Specify a public key to inject into the guest, providing ssh access to the default cloud-init user account. The account name is different per distro cloud image. Some common ones are documented here: https://docs.openstack.org/image-guide/obtain-images.html
network-config= Specify a cloud-init network-config file to add directly to the iso.
Starting install... Password for first root login is: b5lqFbPwLNQT5vKI <-----------------密码在这 Allocating 'cloud-init-linux2.qcow2' | 0 B 00:00:00 ... Creating domain... | 0 B 00:00:00 Domain creation completed.
尝试登陆cloud-init-linux2
1 2 3 4 5 6 7 8 9 10 11
[cshrimp-a300 ~]# virsh console cloud-init-linux2 Connected to domain 'cloud-init-linux2' Escape character is ^] (Ctrl + ])
localhost login: root Password: b5lqFbPwLNQT5vKI You are required to change your password immediately (administrator enforced). Current password: b5lqFbPwLNQT5vKI New password: your_new_password Retype new password: your_new_password [root@localhost ~]#
查看虚拟机ip
1 2 3 4
[cshrimp-a300 ~]# virsh domifaddr cloud-init-linux2 Name MAC address Protocol Address ------------------------------------------------------------------------------- vnet4 52:54:00:a3:0e:a1 ipv4 192.168.122.108/24
尝试用ssh登陆
1 2 3 4 5 6 7 8 9 10
[cshrimp@cshrimp-a300 ~]$ ssh [email protected] The authenticity of host '192.168.122.108 (192.168.122.108)' can't be established. ED25519 key fingerprint is SHA256:r2B7xMRj2qNgUlsywg2QosnNcXeBykdYHkMa2L1A3Js. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.122.108' (ED25519) to the list of known hosts. Activate the web console with: systemctl enable --now cockpit.socket
Last login: Thu Aug 8 09:31:21 2024 [root@localhost ~]#