# Unable to set root password on vm using ROOT\_PASSWORD

**URL:** <https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394>\
**Category:** Product Support\
**Created:** [March 11, 2015, 4:56pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394 "2015-03-11T16:56:27Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiranranjane](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kiranranjane/32/6207_2.png) [@kiranranjane](https://forum.opennebula.io/u/kiranranjane)\
**Post date:** [March 11, 2015, 4:56pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/1 "2015-03-11T16:56:27Z")

</div>

Hello Guys,

Version - 4.12 , Installed from ubuntu repo

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.

Regards  
Kiran Ranjane

---

<div class="post-metadata">

**Author:** ![anandharaj](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@anandharaj](https://forum.opennebula.io/u/anandharaj)\
**Post date:** [March 12, 2015, 3:30am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/2 "2015-03-12T03:30:15Z")

</div>

It should be USER\_PASSWORD (unless this name changed in 4.12)

---

<div class="post-metadata">

**Author:** ![kiranranjane](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kiranranjane/32/6207_2.png) [@kiranranjane](https://forum.opennebula.io/u/kiranranjane)\
**Post date:** [March 12, 2015, 10:49am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/3 "2015-03-12T10:49:12Z")

</div>

Hi Anandharaj,

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”

Regards  
Kiran Ranjane

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [March 12, 2015, 11:21am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/4 "2015-03-12T11:21:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kiranranjane](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kiranranjane/32/6207_2.png) [@kiranranjane](https://forum.opennebula.io/u/kiranranjane)\
**Post date:** [March 12, 2015, 11:53am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/5 "2015-03-12T11:53:16Z")

</div>

Hi Javi,

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.

Thanks  
Kiran Ranjane

---

<div class="post-metadata">

**Author:** ![bpsRobert](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@bpsRobert](https://forum.opennebula.io/u/bpsRobert)\
**Post date:** [March 12, 2015, 1:10pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/6 "2015-03-12T13:10:48Z")

</div>

Also kiranranjane:

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.

-Robert

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [March 12, 2015, 2:16pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/7 "2015-03-12T14:16:40Z")

</div>

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.

> **[OpenNebula/addon-context-linux](https://github.com/OpenNebula/addon-context-linux)**
>
> Linux VM Contextualization. Contribute to OpenNebula/addon-context-linux development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![kiranranjane](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kiranranjane/32/6207_2.png) [@kiranranjane](https://forum.opennebula.io/u/kiranranjane)\
**Post date:** [March 12, 2015, 3:23pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/8 "2015-03-12T15:23:11Z")

</div>

Thanks Javi, I will try the above route and also will open a feature request.

Regards  
Kiran Ranjane

---

<div class="post-metadata">

**Author:** ![Amit\_Kumar](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/amit_kumar/32/7867_2.png) [@Amit\_Kumar](https://forum.opennebula.io/u/Amit_Kumar)\
**Post date:** [April 16, 2017, 3:22pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/10 "2017-04-16T15:22:29Z")

</div>

Hi,

I am using Ubuntu image from marketplace. I am trying following steps to set root password

1. created a file “[root-password.sh](http://root-password.sh)”  
#!/bin/sh

if [-n “$ROOT\_PASSWORD”]; then  
echo “root:$ROOT\_PASSWORD” | chpasswd  
fi

1. Then upload it in the Files & Kernels. Set its name to like “[root-password.sh](http://root-password.sh)”

2. Then in the VM template -\> Context --\> Configuration add User input with the following attributes:  
Name: ROOT\_PASSWORD  
Type: password  
Description: any description (optional?)

3. Then select Files (next under Configuration) and select the imported script.

4. In the Init scripts field type the file’s name - same as the one you set in Files & Kernels. “[root-password.sh](http://root-password.sh)”

5. 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.

---

<div class="post-metadata">

**Author:** ![ranjith](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ranjith/32/5081_2.png) [@ranjith](https://forum.opennebula.io/u/ranjith)\
**Post date:** [April 17, 2017, 8:29am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/11 "2017-04-17T08:29:24Z")

</div>

Where will be /etc/one-context.d file is stored. Is it in Frontend or in Node. Do i have to create a new file?

---

<div class="post-metadata">

**Author:** ![mosharaflink](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/mosharaflink/32/5953_2.png) [@mosharaflink](https://forum.opennebula.io/u/mosharaflink)\
**Post date:** [March 7, 2019, 6:58am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/12 "2019-03-07T06:58:01Z")

</div>

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??

---

<div class="post-metadata">

**Author:** ![gbernardes](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@gbernardes](https://forum.opennebula.io/u/gbernardes)\
**Post date:** [March 12, 2019, 11:56am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/13 "2019-03-12T11:56:09Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![mosharaflink](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/mosharaflink/32/5953_2.png) [@mosharaflink](https://forum.opennebula.io/u/mosharaflink)\
**Post date:** [March 13, 2019, 4:20am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/14 "2019-03-13T04:20:15Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![gbernardes](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@gbernardes](https://forum.opennebula.io/u/gbernardes)\
**Post date:** [March 15, 2019, 12:52pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/15 "2019-03-15T12:52:29Z")

</div>

@mosharaflink What distro do you using in VM?

---

<div class="post-metadata">

**Author:** ![mosharaflink](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/mosharaflink/32/5953_2.png) [@mosharaflink](https://forum.opennebula.io/u/mosharaflink)\
**Post date:** [March 18, 2019, 4:00am UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/16 "2019-03-18T04:00:22Z")

</div>

@gbernardes I am using cross distro in which Ubuntu, CentOS are used as primarily.

---

<div class="post-metadata">

**Author:** ![gbernardes](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@gbernardes](https://forum.opennebula.io/u/gbernardes)\
**Post date:** [March 19, 2019, 8:32pm UTC](https://forum.opennebula.io/t/unable-to-set-root-password-on-vm-using-root-password/394/17 "2019-03-19T20:32:28Z")

</div>

@mosharaflink, I`m using Centos, and removing /etc/one-context.d/loc-20-set-username-password have been sufficient for my
