I downoaded image from marketplace - Ubuntu 14.04 - KVM and added ROOT_PASSWORD under contex > custom vars - Key as ROOT_PASSWORD and Value as “password generated fro open ssl command”
openssl passwd -1 test | base64
However after I instantsiate the VM I am unable to login to the vm using same password that was generated.
Could you kindly let me know if I am doing something wrong, I also tried with user inputs under context and still same.
USER_PASSWORD doesn’t work either, It does not set password for root user and according to the docs its ROOT_PASSWORD if you want set a root user password.
Can you confirm if this works for you, May be I am doing something wrong,
Is this the right path where I need to add the values?
Under contex > custom vars - Key as ROOT_PASSWORD and Value as “OpenSSL Password”
Linux context packages do not change any password. They can only set the authorized keys of root user with the variable SSH_PUBLIC_KEY. The only way to access the machine is using the ssh private key to log as root.
If you need to change the actual password of a user you can add a script in /etc/one-context.d for example called 99-passwd that uses that variable to change the password. Something like:
usermod -p "$ROOT_PASSWORD" root
Make sure the script is executable.
Also check that in sshd configuration password authentication is not disabled.
I read this in Virtual Router Section So I thought it is applied to all Linux os. May I know what modification were done inside the router because it does not need to add a script in the context.
The appliance is based on alpinelinux. There’s only one user account: root. There is no default password for the root account, however, it can be specified in the CONTEXT section along with root’s public key.
SSH_PUBLIC_KEY: If set, it will be set as root’s authorized_keys.
ROOT_PASSWORD: To change the root account password use this attribute. It expects the password in an encrypted format as returned by openssl passwd -1 and encoded in base64. For example, to generate the password test, you will need to issue this command: openssl passwd -1 test | base64.
Be advised that the standard Ubuntu 14.04 image from the marketplace, does not allow root login via ssh using a password, in /etc/ssh/sshd_conf. So there are other variables in there that you’ll need to modify.
The virtual router is a special case and does not use the standard contextualization package. I do not have the scripts for the Virtual Router at hand, some of my colleagues my be able to help. Those are custom made scripts for the distro that is running and probably will enter in conflict with the context packages.
I think the easiest route would be doing something like I’ve explained before. You can also open an issue in the context packages repo so that feature is included. It’s only a context package feature, it does not need any change to OpenNebula.
if [ -n “$ROOT_PASSWORD” ]; then
echo “root:$ROOT_PASSWORD” | chpasswd
fi
Then upload it in the Files & Kernels. Set its name to like “root-password.sh”
Then in the VM template -> Context --> Configuration add User input with the following attributes:
Name: ROOT_PASSWORD
Type: password
Description: any description (optional?)
Then select Files (next under Configuration) and select the imported script.
In the Init scripts field type the file’s name - same as the one you set in Files & Kernels. “root-password.sh”
With the above configuration in the VM instantiation dialog custom attibutes “password” is given and started the VM and use it to login in the VNC console.
unfortunately password is not changed. can someone help here.
This solution is works for me. I just change the Name: ROOT_PASSWORD to Name: PASSWORD.
but, the problem I am getting is, after login to the VM with given password and changing the password adn reboot the VM. New Passwoed does not works but old password is still working. Any solution for this??
@mosharaflink, this happen because when you use the attribute PASSWORD in VM Context this is applied ever when VM starts, overwriting any passoword modification made in SO.
If you want use attribute PASSWORD in VM Context and alter the password in VM, you need remove or change file /etc/one-context.d/loc-20-set-username-password in VM.
@gbernardes, Thank you for the update. I have tried to disable the file by hashing all the line. After then changing the password still does not works for me. After password change and reboot the server will revert to contextual password.
Please share a guideline if you have done this. Thank you.