重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1658|回复: 0
打印 上一主题 下一主题

修改openstack centos镜像默认root密码

[复制链接]
跳转到指定楼层
楼主
发表于 2017-11-3 15:56:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 郑全 于 2017-11-3 15:59 编辑

概要:
在新建虚拟机的过程中,可以对root密码进行初始化。这样可以保障虚拟机的安全,同时也可以给用户自定义root密码的机会。


步骤:修改控制节点的nova配置项:

首先修改nova的配置文件。文件位置 /etc/nova/nova.conf
inject_password改为True

[libvirt]

# There is no agent needed within the image to do this. If *libguestfs* is
# available on the host, it will be used. Otherwise *nbd* is used. Thefile
# system of the image will be mounted and the admin password, which isprovided
# in the REST API call will be injected as password for the root user. Ifno
# root user is available, the instance won't be launched and an error isthrown.
# Be aware that the injection is *not* possible when the instance getslaunched
# from a volume.
#
# Possible values:
#
# * True: Allows the injection.
# * False (default): Disallows the injection. Any via the REST API provided
# admin password will be silently ignored.
#
# Related options:
#
# * ``inject_partition``: That option will decide about the discovery andusage
#   of the file system. It also candisable the injection at all.
#  (boolean value)
inject_password=true



重启nova服务:
systemctl restart openstack-nova-*




然后在创建虚拟机的过程注入脚本


                               
登录/注册后可看大图



                               
登录/注册后可看大图



                               
登录/注册后可看大图


[img][/img]



[img][/img]



如下:
#!/bin/sh
passwd root<<EOF
sztech
sztech
EOF

sztech替换成你的密码

注意下面的配置驱动一定要勾上,不然虚拟机初始化root密码会失败的。


                               
登录/注册后可看大图


centos系统则需要过一段时间才能生效(我测试的时间大概是5-15分钟期间)。
[img][/img]

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-26 11:25 , Processed in 0.154891 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表