How to change default root password?

Solution Verified - Updated -

Issue

When instance is created on OpenStack, root password won't be displayed by default. In case that you would not like, or just forget to inject any keypairs into any instances or only private ip address is assigned to instance, there is no way to login to instances unless you know default non-root account and its password.


How to change password of root account

1. To find out default non-root account and its password.
When you launched instance successfully, there should be console log located at:

  /var/lib/nova/instances/${instance id}/console.log

In this log file, there are information, login account and password.
Note: "nova boot" was skipped since it's not in the scope of this documentation.

~# nova list
+--------------------------------------+-----------+---------+------------+-------------+------------------+
| ID                                   | Name      | Status  | Task State | Power State | Networks         |
+--------------------------------------+-----------+---------+------------+-------------+------------------+
| caadcd24-3f6d-47bc-8d46-00fb0780bee7 | instancer | SHUTOFF | -          | Running     | private=10.0.0.3 |
+--------------------------------------+-----------+---------+------------+-------------+------------------+
 
~# tail /var/lib/nova/instances/caadcd24-3f6d-47bc-8d46-00fb0780bee7/console.log
\___//_//_/  /_/   \____/___/ 
   http://cirros-cloud.net


login as 'cirros' user. default password: 'cubswin:)'. use 'sudo' for root.

2. To create security group for ssh into instance.
By default there is no port opened on launched an instance. You should create security group accordingly.
The following is an example to open port 22 to enable us to ssh into an instance.

~# nova secgroup-create ssh "For SSH Access"

~# nova secgroup-list
+--------------------------------------+--------------+--------------------------+
| Id                                   | Name         | Description              |
+--------------------------------------+--------------+--------------------------+
| 9a90aaa1-ee2e-448d-82ca-733017120568 | default      | Default security group   |
| aac072d8-3621-45b3-a187-f0b2aa836bc9 | ssh | For SSH Access |
+--------------------------------------+--------------+--------------------------+

~# nova secgroup-add-rule \
aac072d8-3621-45b3-a187-f0b2aa836bc9 tcp 22 22 0.0.0.0/0

3. To apply security group to instance.

~# nova add-secgroup \
caadcd24-3f6d-47bc-8d46-00fb0780bee7 \
aac072d8-3621-45b3-a187-f0b2aa836bc9

4. To ssh to instance and change root password.

~# ip netns
qrouter-1839a1ef-9c7c-4c62-bae9-0a0f9e65f8e9
qdhcp-83a3c440-92a6-4e62-98bd-2f3e1b8b180d

~#ip netns exec \
qdhcp-83a3c440-92a6-4e62-98bd-2f3e1b8b180d \
ssh cirros@10.0.0.3
cirros@10.0.0.3's password: 

$ sudo su -

# passwd
Changing password for root
New password: ${some super strong string}

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content