OpenStack Horizon创建虚拟机时增加虚拟机OS用户

来源:互联网 发布:程序员的呐喊 在线阅读 编辑:程序博客网 时间:2024/06/15 02:46

背景

  通过OpenStack的Horizon使用镜像创建虚拟机(以Ubuntu为例),如果不知道镜像的用户名和密码,在创建好虚拟机之后,无法登录虚拟机的OS。因此,我们需要一种方法,创建虚拟机时增加用户。

方法

  Horizon创建虚拟机时,在创建页面-“配置Tab”选项-“Customization Script”中,输入以下字符串:

#!/bin/shpasswd ubuntu<<EOFubuntuubuntuEOFsed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_configservice ssh restart

  然后创建虚拟机,虚拟机OS启动后,就可以通过第三、四行设置的ubuntu/ubuntu来登录了。

0 0
原创粉丝点击