修改openstack Ubuntu镜像的默认用户的密码

来源:互联网 发布:手机淘宝怎么看直播间 编辑:程序博客网 时间:2024/05/11 16:06

转载:https://github.com/renhuailin/MyDocs/blob/master/OpenStack-Notes.md#修改ubuntu镜像的默认用户的密码

Ubuntu官方提供的OpenStack镜像是用Key来登录的,太麻烦,可以改成用密码来登录。

修改image的工具叫:guestfish

Ubuntu 14.04下安装:

# apt-get install libguestfs-tools

用它来打开一个镜像

# guestfish --rw -a trusty-server-cloudimg-amd64-disk1.img

guestfish的命令行提示符是><fs>

你需要先运行这个镜像

><fs> run

如果这一步报错:

libguestfs: error: /usr/bin/supermin-helper exited with error status 1.To see full error messages you may need to enable debugging.See http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs

则请退出guestfish,然后运行下面的命令。

# update-guestfs-appliance

更新完后再重新进入镜像。

列出所有的文件系统

><fs> list-filesystems/dev/sda1: ext4

挂载到根目录

><fs> mount /dev/sda1 /

编辑文件/etc/cloud/cloud.cfg,因为我们要修改默认用户ubuntu的密码,所以,很简单加入下面的内容就行了。

/#cloud-configpassword: openstackchpasswd: { expire: False }ssh_pwauth: True

退出后,把这个镜像加到OpenStack里就行了。

参考: http://docs.openstack.org/image-guide/content/ch_modifying_images.html

https://ask.openstack.org/en/question/5531/defining-default-user-password-for-ubuntu-cloud-image/

For other options in cloud.cfg file: http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/doc/examples/cloud-config.txt

0 0
原创粉丝点击