[SOLVED] Can't login to CentOS 7 cloud-init with Username & Password via Console

Razva

Renowned Member
Dec 3, 2013
252
10
83
Romania
cncted.com
I'm running this in order to initialize a CentOS 7 VM:

Code:
# wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.raw.tar.gz
# tar -xzf CentOS-7-x86_64-GenericCloud.raw.tar.gz
# rm -rf CentOS-7-x86_64-GenericCloud.raw.tar.gz
# qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr1
# qm importdisk 9000 CentOS-7-x86_64-GenericCloud-20180930_02.raw zfs
(100.00/100%)
# qm set 9000 --scsihw virtio-scsi-pci --scsi0 zfs:vm-9000-disk-0
update VM 9000: -scsi0 zfs:vm-9000-disk-0 -scsihw virtio-scsi-pci
# qm set 9000 --ide2 zfs:cloudinit
update VM 9000: -ide2 zfs:cloudinit
# qm set 9000 --boot c --bootdisk scsi0
update VM 9000: -boot c -bootdisk scsi0
# qm set 9000 --serial0 socket --vga serial0
update VM 9000: -serial0 socket -vga serial0

After that I'm going to the VM's "Cloud-Init" section and set the User, Password, DNS Servers and IP Config in the form of "192.168.1.10/27" with "192.168.1.1" as Gateway. I then click on "Regenerate Image"

The VM works but I can't login via "Console", even if the Username was previously correctly set. The only way to login is to use a SSH Key.

Please note that the exact same procedure fully works with Ubuntu.
 
Last edited:
It seems that CentOS's Cloud Images is set to have SSH user/pass disabled by default, which explains why u/p aren't working via SSH.

Still, this doesn't clarifies why I cannot login via Console.
 
Last edited:
After digging into this, it looks like /etc/shadow is modified when making a cloud-init-based password change.

The problem is that I can't login to the Console when using the password provided via cloud-init. The only way to login on the Console is to login via SSH, change the password and then login on the Console.

I'm using the latest Proxmox version.
 
I have used that .ISO without issues, but yes it is a bit strange.

Essentially, you need to add your SSH key in the cloud-init setup (via the GUI), then login via SSH as user "Centos" (capital C).

Once logged in, my memory fails me as to exactly what you need to do but it would involve something like "sudo bash" and/or "su -" to become "real" root, or root enough to set a password for root.

At that point you can login as root via the console using the password you set, but you are still blocked from doing so via ssh I think.

If I recall correctly, there was something in /root/.ssh/authorized_keys or maybe it is /home/centos/.ssh/authorized_keys. I'm sorry not to remember more.

I think the basic problem is that the root user you set via cloud-init is ignored by the cloud-init installed in that image.
 
The regular user in the image is centos unless you change its name in the user box in the proxmox ui. In that case it will make a new user and set it's password. Or if you don't change the user it will set the cents users password. It should never be setting the password for root.
The new user or centos will have sudo rights so no problem.


Like I said before the cloud init is outdated it's trival to make a new template
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!