openstack instance随机密码设置及获取方法

为了强迫用户更改instance的密码,我选择交付随机密码的办法,设置随机密码的方法,进入镜像修改/etc/cloud/cloud.cfg文件即可

chpasswd:
    list: |
        user:RANDOM


这样,创建新的虚机密码就是随机的了,那么管理员如何查询这个随机密码呢?我总结了三个方法(可能有更多的方法):

方法一:

在dashboard上面可以查看:

openstack instance随机密码设置及获取方法_第1张图片


方法二:

通过key登录进vm后,查看文件:

[root@centos-7 ~]# cat /var/log/cloud-init-output.log 
Cloud-init v. 0.7.5 running 'init-local' at Mon, 15 Jan 2018 06:58:06 +0000. Up 14.49 seconds.
Cloud-init v. 0.7.5 running 'init' at Mon, 15 Jan 2018 06:58:27 +0000. Up 35.64 seconds.
ci-info: ++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++
ci-info: +--------+------+--------------+---------------+-------------------+
ci-info: | Device |  Up  |   Address    |      Mask     |     Hw-Address    |
ci-info: +--------+------+--------------+---------------+-------------------+
ci-info: |  lo:   | True |  127.0.0.1   |   255.0.0.0   |         .         |
ci-info: | eth0:  | True | 10.225.10.52 | 255.255.254.0 | fa:16:3e:77:77:6a |
ci-info: +--------+------+--------------+---------------+-------------------+
ci-info: +++++++++++++++++++++++++++++++++++Route info++++++++++++++++++++++++++++++++++++
ci-info: +-------+-----------------+---------------+-----------------+-----------+-------+
ci-info: | Route |   Destination   |    Gateway    |     Genmask     | Interface | Flags |
ci-info: +-------+-----------------+---------------+-----------------+-----------+-------+
ci-info: |   0   |     0.0.0.0     | 10.225.11.247 |     0.0.0.0     |    eth0   |   UG  |
ci-info: |   1   |   10.225.10.0   |    0.0.0.0    |  255.255.254.0  |    eth0   |   U   |
ci-info: |   2   | 169.254.169.254 |  10.225.10.11 | 255.255.255.255 |    eth0   |  UGH  |
ci-info: +-------+-----------------+---------------+-----------------+-----------+-------+
Cloud-init v. 0.7.5 running 'modules:config' at Mon, 15 Jan 2018 06:59:52 +0000. Up 120.22 seconds.
Set the following 'random' passwords


root:8YNhqyecQ
Cloud-init v. 0.7.5 running 'modules:final' at Mon, 15 Jan 2018 06:59:53 +0000. Up 120.77 seconds.
Cloud-init v. 0.7.5 finished at Mon, 15 Jan 2018 06:59:53 +0000. Datasource DataSourceOpenStack [net,ver=2].  Up 120.99 seconds


方法三:

通过命令行查看:

[root@cloud ~]# openstack console log show centos-7 | grep root:
[  120.411364] cloud-init[9208]: root:8YNhqyecQ


你可能感兴趣的:(openstack instance随机密码设置及获取方法)